bleh
[mqlkit.git] / templates / Awesome.mqt
blobff69cac8ef9583807b5aa5d2aa9fd5faaec4f12f
1 <expert>\r
2 type=INDICATOR_ADVISOR\r
3 description=Awesome Oscilator\r
4 separate_window=1\r
5 used_buffers=3;\r
6 <ind>\r
7 color=Green\r
8 type=DRAW_HISTOGRAM\r
9 </ind>\r
10 <ind>\r
11 color=Red\r
12 type=DRAW_HISTOGRAM\r
13 </ind>\r
14 </expert>\r
15 #header#\r
16 #property copyright "#copyright#"\r
17 #property link      "#link#"\r
19 #indicator_properties#\r
20 #extern_variables#\r
21 #mapping_buffers#\r
22 //---- indicator buffers\r
23 double ExtGreenBuffer[];\r
24 double ExtRedBuffer[];\r
25 double ExtMABuffer[];\r
26 //+------------------------------------------------------------------+\r
27 //| Custom indicator initialization function                         |\r
28 //+------------------------------------------------------------------+\r
29 int init()\r
30   {\r
31    #buffers_used#\r
32 //---- drawing settings\r
33    #indicators_init#\r
34    IndicatorDigits(5);\r
35    SetIndexDrawBegin(0,34);\r
36    SetIndexDrawBegin(1,34);\r
37 //---- indicator buffers mapping\r
38    SetIndexBuffer(0, ExtGreenBuffer);\r
39    SetIndexBuffer(1, ExtRedBuffer);\r
40    SetIndexBuffer(2, ExtMABuffer);\r
41 //---- name for DataWindow and indicator subwindow label\r
42    IndicatorShortName("AO");\r
43 //---- initialization done\r
44    return(0);\r
45   }\r
46 //+------------------------------------------------------------------+\r
47 //| Awesome Oscillator                                               |\r
48 //+------------------------------------------------------------------+\r
49 int start()\r
50   {\r
51    int    limit;\r
52    int    counted_bars=IndicatorCounted();\r
53    double prev,current;\r
54 //---- check for possible errors\r
55    if(counted_bars<0) return(-1);\r
56    //---- last counted bar will be recounted\r
57    if(counted_bars>0) counted_bars--;\r
58    limit=Bars-counted_bars;\r
59 //---- macd counted in the 1-st additional buffer\r
60    for(int i=0; i<limit; i++)\r
61       ExtMABuffer[i]=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,i);\r
62 //---- dispatch values between 2 buffers\r
63    bool up=true;\r
64    for(i=limit-1; i>=0; i--)\r
65      {\r
66       current=ExtMABuffer[i];\r
67       prev=ExtMABuffer[i+1];\r
68       if(current>prev) up=true;\r
69       if(current<prev) up=false;\r
70       if(!up)\r
71         {\r
72          ExtRedBuffer[i]=current;\r
73          ExtGreenBuffer[i]=0.0;\r
74         }\r
75       else\r
76         {\r
77          ExtGreenBuffer[i]=current;\r
78          ExtRedBuffer[i]=0.0;\r
79         }\r
80      }\r
81 //---- done\r
82    return(0);\r
83   }\r
84 //+------------------------------------------------------------------+\r