2 type=INDICATOR_ADVISOR
\r
3 description=Accelerator Oscilator
\r
16 #property copyright "#copyright#"
\r
17 #property link "#link#"
\r
19 #indicator_properties#
\r
22 //---- indicator buffers
\r
23 double ExtGreenBuffer[];
\r
24 double ExtRedBuffer[];
\r
25 double ExtMABuffer[];
\r
27 //+------------------------------------------------------------------+
\r
28 //| Custom indicator initialization function |
\r
29 //+------------------------------------------------------------------+
\r
33 //---- indicator buffers mapping
\r
34 SetIndexBuffer(0, ExtGreenBuffer);
\r
35 SetIndexBuffer(1, ExtRedBuffer);
\r
36 SetIndexBuffer(2, ExtMABuffer);
\r
37 SetIndexBuffer(3, ExtBuffer);
\r
38 //---- drawing settings
\r
42 SetIndexDrawBegin(0,38);
\r
43 SetIndexDrawBegin(1,38);
\r
44 //---- name for DataWindow and indicator subwindow label
\r
45 IndicatorShortName("AC");
\r
46 //---- initialization done
\r
49 //+------------------------------------------------------------------+
\r
50 //| Accelerator/Decelerator Oscillator |
\r
51 //+------------------------------------------------------------------+
\r
55 int counted_bars=IndicatorCounted();
\r
56 double prev,current;
\r
57 //---- check for possible errors
\r
58 if(counted_bars<0) return(-1);
\r
59 //---- last counted bar will be recounted
\r
60 if(counted_bars>0) counted_bars--;
\r
61 limit=Bars-counted_bars;
\r
62 //---- macd counted in the 1-st additional buffer
\r
63 for(int i=0; i<limit; i++)
\r
64 ExtMABuffer[i]=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,i);
\r
65 //---- signal line counted in the 2-nd additional buffer
\r
66 for(i=0; i<limit; i++)
\r
67 ExtBuffer[i]=iMAOnArray(ExtMABuffer,Bars,5,0,MODE_SMA,i);
\r
68 //---- dispatch values between 2 buffers
\r
70 for(i=limit-1; i>=0; i--)
\r
72 current=ExtMABuffer[i]-ExtBuffer[i];
\r
73 prev=ExtMABuffer[i+1]-ExtBuffer[i+1];
\r
74 if(current>prev) up=true;
\r
75 if(current<prev) up=false;
\r
78 ExtRedBuffer[i]=current;
\r
79 ExtGreenBuffer[i]=0.0;
\r
83 ExtGreenBuffer[i]=current;
\r
84 ExtRedBuffer[i]=0.0;
\r
90 //+------------------------------------------------------------------+
\r