//+------------------------------------------------------------------+ //| ProjectName | //| Copyright 2012, CompanyName | //| http://www.companyname.net | //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 Black #property indicator_color2 Green #property indicator_color3 Green #property indicator_color4 Red #property indicator_color5 Red //---- indicator buffers double ExtACBuffer[]; double ExtUpBuffer[]; double ExtUp2Buffer[]; double ExtDnBuffer[]; double ExtDn2Buffer[]; double ExtMacdBuffer[]; double ExtSignalBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorShortName("AC"); //--- 2 additional buffers are used for counting. IndicatorBuffers(7); //--- drawing settings SetIndexStyle(0,DRAW_NONE); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexStyle(2,DRAW_HISTOGRAM,0,1); SetIndexStyle(3,DRAW_HISTOGRAM); SetIndexStyle(4,DRAW_HISTOGRAM,0,1); IndicatorDigits(Digits+2); SetIndexDrawBegin(0,38); SetIndexDrawBegin(1,38); SetIndexDrawBegin(2,38); SetIndexDrawBegin(3,38); SetIndexDrawBegin(4,38); //--- all indicator buffers mapping SetIndexBuffer(0,ExtACBuffer); SetIndexBuffer(1,ExtUpBuffer); SetIndexBuffer(2,ExtUp2Buffer); SetIndexBuffer(3,ExtDnBuffer); SetIndexBuffer(4,ExtDn2Buffer); SetIndexBuffer(5,ExtMacdBuffer); SetIndexBuffer(6,ExtSignalBuffer); //--- name for DataWindow and indicator subwindow label SetIndexLabel(1,NULL); SetIndexLabel(2,NULL); SetIndexLabel(3,NULL); SetIndexLabel(4,NULL); return(0); } //+------------------------------------------------------------------+ //| Accelerator/Decelerator Oscillator | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); double prev,current,early; //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- macd counted in the 1-st additional buffer for(int i=0; i=0; i--) { current=ExtMacdBuffer[i]-ExtSignalBuffer[i]; prev=ExtMacdBuffer[i+1]-ExtSignalBuffer[i+1]; early=ExtMacdBuffer[i+2]-ExtSignalBuffer[i+2]; if(current>prev) //----условие первое { up=true; } else { up=false; } if((current-prev)<=(prev-early)) //----условие второе { change=true; } else { change=false; } if(!up) { if(!change) { ExtUpBuffer[i]=0.0; ExtUp2Buffer[i]=current; ExtDnBuffer[i]=0.0; ExtDn2Buffer[i]=0.0; } else { ExtUpBuffer[i]=current; ExtUp2Buffer[i]=0.0; ExtDnBuffer[i]=0.0; ExtDn2Buffer[i]=0.0; } } else { if(!change) { ExtUpBuffer[i]=0.0; ExtUp2Buffer[i]=0.0; ExtDnBuffer[i]=0.0; ExtDn2Buffer[i]=current; } else { ExtUpBuffer[i]=0.0; ExtUp2Buffer[i]=0.0; ExtDnBuffer[i]=current; ExtDn2Buffer[i]=0.0; } } ExtACBuffer[i]=current; } //---- done return(0); } //-------------------------------------------------------+