MAOnDay
// MAonDay ------ 每天新算的均线 #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Red extern int 均类 =0; extern int 用价 = 0; extern int 大时框 = 1440; bool Activate; datetime 当前日, 最后日; double 线组[]; int Count; double MA[]; //----------------------------+ int init() { Activate= False; if(Period()>=大时框){ Comment("图表时框不可超过参数设定!"); return(0); } SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0, MA); SetIndexEmptyValue(0, 0); ArrayResize(线组, MathCeil(大时框/Period())+1); ArrayInitialize(线组, 0); Activate= True; return(0); } //----------------------------+ int start() { if(Activate==false) return(0); int limit, 已计= IndicatorCounted(); if(已计>0) 已计--; limit= iBarShift(Symbol(), 0, iTime(Symbol(), 大时框, iBarShift(Symbol(), 大时框, Time[Bars-已计]))); 最后日= 1; for (int i=limit; i>=0; i--){ 当前日= iTime(Symbol(), 大时框, iBarShift(Symbol(), 大时框, Time)); //--初归位 if(最后日!=当前日){ ArrayInitialize(线组, 0); Count= 0; 最后日= 当前日; } //--选用价线 switch(用价){ case 0: 线组[Count]= Close; break; case 1: 线组[Count]= Open; break; case 2: 线组[Count]= High; break; case 3: 线组[Count]= Low; break; case 4: 线组[Count]= (High+Low)/2; break; case 5: 线组[Count]= (High+Low+Close)/3; break; case 6: 线组[Count]= (High+Low+2*Close)/4; break; } //--MA化 MA= iMAonArray(线组, Count+1, Count+1, 0, 均类, 0); Count++; } return(0); } //----------------------------+ |
打赏
最新创建圈子
- 新闻EA运行效果图圈 2019-05-05
圈主:admin 帖子:1