请版主帮忙看看,到底哪里出错了(已解决)
目的:在系统bands的基础上,再输出一条线,价格上触布林上线输出1,下触布林线下线输出2。没想明白错在哪个地方,请帮忙指点。 //+------------------------------------------------------------------+ //| Bands.mq4 | //| Copyright ?2005, metaQuotes Software Corp. | //| //+------------------------------------------------------------------+ #property copyright "Copyright ?2005, metaQuotes Software Corp." #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 LightSeaGreen #property indicator_color2 LightSeaGreen #property indicator_color3 LightSeaGreen #property indicator_color4 LightSeaGreen //---- indicator parameters extern int BandsPeriod=20; extern int BandsShift=0; extern double BandsDeviations=2.0; int mark=0; //---- buffers double MovingBuffer[]; double UpperBuffer[]; double LowerBuffer[]; double out[]; double ll[]; double hh[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,MovingBuffer); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,UpperBuffer); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,LowerBuffer); SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(3,out); //---- SetIndexDrawBegin(0,BandsPeriod+BandsShift); SetIndexDrawBegin(1,BandsPeriod+BandsShift); SetIndexDrawBegin(2,BandsPeriod+BandsShift); SetIndexDrawBegin(3,BandsPeriod+BandsShift); //---- return(0); } //+------------------------------------------------------------------+ //| Bollinger Bands | //+------------------------------------------------------------------+ int start() { int i,k,counted_bars=IndicatorCounted(); double deviation; double sum,oldval,newres; //---- if(Bars=i) { newres=Close[k]-oldval; sum+=newres*newres; k--; } deviation=BandsDeviations*MathSqrt(sum/BandsPeriod); UpperBuffer<i>=oldval+deviation; LowerBuffer<i>=oldval-deviation; ll<i>=iLow(0,0,i); hh<i>=iHigh(0,0,i); if(hh<i>>UpperBuffer<i>&&ll<i>>LowerBuffer<i>&&mark!=1) {mark=1;} if(hh<i> |
打赏
最新创建圈子
- 新闻EA运行效果图圈 2019-05-05
圈主:admin 帖子:1