//+-------------------------------------------------------------------+ //| 4TF_AO_Mov(AM) | //+-------------------------------------------------------------------+ #property copyright "Andrey Matvievskiy" #property link "" #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 5.5 #property indicator_buffers 8 #property indicator_color1 Red #property indicator_color2 Lime #property indicator_color3 Red #property indicator_color4 Lime #property indicator_color5 Red #property indicator_color6 Lime #property indicator_color7 Red #property indicator_color8 Lime extern int AO_PeriodMA1 = 34; extern int AO_PeriodMA2 = 5; extern int AO_TypeMA1 = 0; extern int AO_TypeMA2 = 0; extern int AO_PriceMA1 = 4; extern int AO_PriceMA2 = 4; extern int AO_TF1 = 0; extern int AO_TF2 = 0; extern int AO_Shift1 = 0; extern int AO_Shift2 = 0; extern int BarSymbol = 110; extern int BarWidth = 0; extern color BarColorUp = Lime; extern color BarColorDown = Red; extern color TextColor = Blue; extern int MaxBars=150; extern int UniqueNum = 1963; double Gap = 1; // Gap between the lines of bars //---- buffers double buf4_up[]; double buf4_down[]; double buf3_up[]; double buf3_down[]; double buf2_up[]; double buf2_down[]; double buf1_up[]; double buf1_down[]; double Y1,Y2; string shortname = ""; int Period_1, Period_2, Period_3, Period_4; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexStyle(0,DRAW_ARROW,0,BarWidth,BarColorUp); SetIndexArrow(0,BarSymbol); SetIndexBuffer(0,buf1_up); SetIndexEmptyValue(0,0.0); SetIndexStyle(1,DRAW_ARROW,0,BarWidth,BarColorDown); SetIndexArrow(1,BarSymbol); SetIndexBuffer(1,buf1_down); SetIndexEmptyValue(1,0.0); SetIndexStyle(2,DRAW_ARROW,0,BarWidth,BarColorUp); SetIndexArrow(2,BarSymbol); SetIndexBuffer(2,buf2_up); SetIndexEmptyValue(2,0.0); SetIndexStyle(3,DRAW_ARROW,0,BarWidth,BarColorDown); SetIndexArrow(3,BarSymbol); SetIndexBuffer(3,buf2_down); SetIndexEmptyValue(3,0.0); SetIndexStyle(4,DRAW_ARROW,0,BarWidth,BarColorUp); SetIndexArrow(4,BarSymbol); SetIndexBuffer(4,buf3_up); SetIndexEmptyValue(4,0.0); SetIndexStyle(5,DRAW_ARROW,0,BarWidth,BarColorDown); SetIndexArrow(5,BarSymbol); SetIndexBuffer(5,buf3_down); SetIndexEmptyValue(5,0.0); SetIndexStyle(6,DRAW_ARROW,0,BarWidth,BarColorUp); SetIndexArrow(6,BarSymbol); SetIndexBuffer(6,buf4_up); SetIndexEmptyValue(6,0.0); SetIndexStyle(7,DRAW_ARROW,0,BarWidth,BarColorDown); SetIndexArrow(7,BarSymbol); SetIndexBuffer(7,buf4_down); SetIndexEmptyValue(7,0.0); IndicatorDigits(0); getPeriod(); shortname = "4TF_AO_Mov(AM)"; IndicatorShortName(shortname); SetIndexLabel(0,"Bars("+Period_1+")"); SetIndexLabel(1,"Bars("+Period_1+")"); SetIndexLabel(2,"Bars("+Period_2+")"); SetIndexLabel(3,"Bars("+Period_2+")"); SetIndexLabel(4,"Bars("+Period_3+")"); SetIndexLabel(5,"Bars("+Period_3+")"); SetIndexLabel(6,"Bars("+Period_4+")"); SetIndexLabel(7,"Bars("+Period_4+")"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- the last counted bar will be recounted if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars+Period_4/Period(); int i,tf; //-------------------------------1---------------------------------------- double dif = Time[0] - Time[1]; for ( i=ObjectsTotal()-1; i>-1; i--) { if (StringFind(ObjectName(i),"FF_"+UniqueNum+"_") >= 0) ObjectDelete(ObjectName(i)); } double shift = 0.2; for ( tf=1; tf<=4; tf++) { string txt = "??"; double gp; switch (tf) { case 1: txt = tf2txt(Period_1); gp = 1 + Gap*3 + shift; break; case 2: txt = tf2txt(Period_2); gp = 1 + Gap*2 + shift; break; case 3: txt = tf2txt(Period_3); gp = 1 + Gap + shift; break; case 4: txt = tf2txt(Period_4); gp = 1.5 + shift; break; } string name = "FF_"+UniqueNum+"_"+tf+"_"+txt; ObjectCreate(name, OBJ_TEXT, WindowFind(shortname), iTime(NULL,0,0)+dif*3, gp); ObjectSetText(name, txt,8,"Arial", TextColor); } //-------------------------------2---------------------------------------- datetime TimeArray_1[], TimeArray_2[], TimeArray_3[], TimeArray_4[]; ArrayCopySeries(TimeArray_1,MODE_TIME,Symbol(),Period_1); ArrayCopySeries(TimeArray_2,MODE_TIME,Symbol(),Period_2); ArrayCopySeries(TimeArray_3,MODE_TIME,Symbol(),Period_3); ArrayCopySeries(TimeArray_4,MODE_TIME,Symbol(),Period_4); int i1=0, i2=0, i3=0, i4=0, yy; for(i=0, i1=0, i2=0, i3=0, i4=0;iPeriod()) { int PerINT=TimeFrame/Period()+1; datetime TimeArr[]; ArrayResize(TimeArr,PerINT); ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period()); for(i=0;i=TimeArray[0]) { /******************************************************** Refresh buffers: buffer[i] = buffer[0]; ********************************************************/ buf4_up[i]=buf4_up[0]; buf4_down[i]=buf4_down[0]; buf3_up[i]=buf3_up[0]; buf3_down[i]=buf3_down[0]; buf2_up[i]= buf2_up[0]; buf2_down[i]= buf2_down[0]; buf1_up[i]=buf1_up[0]; buf1_down[i]= buf1_down[0]; //---- } } } //+++++++++++++++++++++++++++++++++++++++++++++++ Raff //+------------- return("??"); }