請幫忙檢查哪裡寫錯,謝謝!! 新评论 skyelephant 2014.12.23 15:47 //+------------------------------------------------------------------+ //| _MySmoothBand.mq5 | //| SkyElephant | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "SkyElephant" #property link "http://www.mql5.com" #property version "1.00" #property strict #property indicator_separate_window #include <MovingAverages.mqh> #property indicator_buffers 1 #property indicator_minimum 0 #property indicator_maximum 25 #property indicator_color1 Blue extern int Length=20; input int BShift=0; double LnBuf[]; int OnInit(void) { IndicatorBuffers(1); IndicatorDigits(Digits); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,LnBuf); SetIndexShift(0,BShift); SetIndexLabel(0,"Length"); if(Length<=0) { Print("Err of Length",Length); return(INIT_FAILED); } SetIndexDrawBegin(0,Length+BShift); return(INIT_SUCCEEDED); } double Highest(const double &array[],int range,int fromIndex) { double res; int i; res=array[fromIndex]; for(i=fromIndex;i>fromIndex-range && i>=0;i--) { if(res<array[i]) res=array[i]; } return(res); } double Lowest(const double &array[],int range,int fromIndex) { double res; int i; res=array[fromIndex]; for(i=fromIndex;i>fromIndex-range && i>=0;i--) { if(res>array[i]) res=array[i]; } return(res); } int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { int i,pos; if(rates_total<=Length || Length<=0) return(0); ArraySetAsSeries(LnBuf,false); ArraySetAsSeries(close,false); if(prev_calculated<1) { for(i=0;i<Length;i++) { LnBuf[i]=EMPTY_VALUE; } } if(prev_calculated>1) pos=prev_calculated-1; else pos=0; for(i=pos;i<rates_total;i++) { if(High[i]==Highest(high,Length,i) || Low[i]==Lowest(low,Length,i)) Length=MathMax(Length-1,5); else Length=MathMin(Length+1,20); LnBuf[i]=Length; } return(rates_total); }-------------------以上為自己寫的指標-------- 參考論壇中已些分享出來的指標剪剪貼貼的.... 主要想法是當K線中的High為近期最高時,Length減去1同樣Low為近期最低時,Length減去1若上述兩項都不符合,則Length加1而Length範圍鎖定在5~20 不過執行結果很奇怪,創新高或新低時,Length都沒有變化。 請各位幫忙檢查,謝謝 自动交易和策略测试 www.mql5.com MQL5:MetaTrader 5客户端内置的交易策略语言。语言允许编写您自己的自动交易系统,技术指标,脚本和函数程序库 enbo lu 2014.12.24 02:30 #1 贴代码请用 SRC。 已修正 Gang Wu 2014.12.25 10:23 #2 mark下, 有空慢慢看 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
-------------------以上為自己寫的指標--------
參考論壇中已些分享出來的指標剪剪貼貼的....
主要想法是
當K線中的High為近期最高時,Length減去1
同樣Low為近期最低時,Length減去1
若上述兩項都不符合,則Length加1
而Length範圍鎖定在5~20
不過執行結果很奇怪,創新高或新低時,Length都沒有變化。
請各位幫忙檢查,謝謝