//+------------------------------------------------------------------+ //| ZeroLag MACD-OsMA(AM).mq4 | //| Andrey Matvievskiy | //| | //+------------------------------------------------------------------+ #property copyright "Andrey Matvievskiy" #property link "" //---- indicator settings #property indicator_separate_window #property indicator_buffers 7 #property indicator_color1 Black #property indicator_color2 Black #property indicator_color3 Teal #property indicator_color4 Red #property indicator_color5 Teal #property indicator_color6 Red #property indicator_color7 Black extern int FastEMA = 12; extern int SlowEMA = 24; extern int SignalEMA = 9; //---- indicator buffers double ExtBuffer0[]; double ExtBuffer1[]; double ExtBuffer2[]; double ExtBuffer3[]; double ExtBuffer4[]; double ExtBuffer5[]; double ExtBuffer6[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- 2 additional buffers are used for counting. IndicatorBuffers(7); //---- drawing settings SetIndexStyle(0,DRAW_NONE); SetIndexStyle(1,DRAW_NONE); SetIndexStyle(2,DRAW_HISTOGRAM,0,2); SetIndexStyle(3,DRAW_HISTOGRAM,0,2); SetIndexStyle(4,DRAW_HISTOGRAM,0,1); SetIndexStyle(5,DRAW_HISTOGRAM,0,1); SetIndexStyle(6,DRAW_NONE); IndicatorDigits(Digits+2); //---- 4 indicator buffers mapping SetIndexBuffer(0,ExtBuffer0); SetIndexBuffer(1,ExtBuffer1); SetIndexBuffer(2,ExtBuffer2); SetIndexBuffer(3,ExtBuffer3); SetIndexBuffer(4,ExtBuffer4); SetIndexBuffer(5,ExtBuffer5); SetIndexBuffer(6,ExtBuffer6); //---- name for DataWindow and indicator subwindow label IndicatorShortName("ZeroLag MACD-OsMA(AM)("+FastEMA+","+SlowEMA+","+SignalEMA+")"); SetIndexLabel(0,NULL); SetIndexLabel(1,NULL); SetIndexLabel(2,NULL); SetIndexLabel(3,NULL); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Accelerator/Decelerator Oscillator | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); double prev1,current1,prev2,current2; limit=Bars-counted_bars; if(counted_bars==0) limit--; for(int i=0; i=0; i--) { current1=ExtBuffer0[i]; prev1=ExtBuffer0[i+1]; if(current1>prev1) up1=true; if(current1prev2) up2=true; if(current2