bleh
[mqlkit.git] / indicators / Alligator.mq4
blob21eb00d369cd36696ead341f9557ee182382ba27
1 //+------------------------------------------------------------------+\r
2 //|                                                    Alligator.mq4 |\r
3 //|                      Copyright © 2004, MetaQuotes Software Corp. |\r
4 //|                                       http://www.metaquotes.net/ |\r
5 //+------------------------------------------------------------------+\r
6 #property copyright "Copyright © 2004, MetaQuotes Software Corp."\r
7 #property link      "http://www.metaquotes.net/"\r
8 \r
9 #property indicator_chart_window\r
10 #property indicator_buffers 3\r
11 #property indicator_color1 Blue\r
12 #property indicator_color2 Red\r
13 #property indicator_color3 Lime\r
14 //---- input parameters\r
15 extern int JawsPeriod=13;\r
16 extern int JawsShift=8;\r
17 extern int TeethPeriod=8;\r
18 extern int TeethShift=5;\r
19 extern int LipsPeriod=5;\r
20 extern int LipsShift=3;\r
21 //---- indicator buffers\r
22 double ExtBlueBuffer[];\r
23 double ExtRedBuffer[];\r
24 double ExtLimeBuffer[];\r
26 //+------------------------------------------------------------------+\r
27 //| Custom indicator initialization function                         |\r
28 //+------------------------------------------------------------------+\r
29 int init()\r
30   {\r
31 //---- line shifts when drawing\r
32    SetIndexShift(0,JawsShift);\r
33    SetIndexShift(1,TeethShift);\r
34    SetIndexShift(2,LipsShift);\r
35 //---- first positions skipped when drawing\r
36    SetIndexDrawBegin(0,JawsShift+JawsPeriod);\r
37    SetIndexDrawBegin(1,TeethShift+TeethPeriod);\r
38    SetIndexDrawBegin(2,LipsShift+LipsPeriod);\r
39 //---- 3 indicator buffers mapping\r
40    SetIndexBuffer(0,ExtBlueBuffer);\r
41    SetIndexBuffer(1,ExtRedBuffer);\r
42    SetIndexBuffer(2,ExtLimeBuffer);\r
43 //---- drawing settings\r
44    SetIndexStyle(0,DRAW_LINE);\r
45    SetIndexStyle(1,DRAW_LINE);\r
46    SetIndexStyle(2,DRAW_LINE);\r
47 //---- index labels\r
48    SetIndexLabel(0,"Gator Jaws");\r
49    SetIndexLabel(1,"Gator Teeth");\r
50    SetIndexLabel(2,"Gator Lips");\r
51 //---- initialization done\r
52    return(0);\r
53   }\r
54 //+------------------------------------------------------------------+\r
55 //| Bill Williams' Alligator                                         |\r
56 //+------------------------------------------------------------------+\r
57 int start()\r
58   {\r
59    int limit;\r
60    int counted_bars=IndicatorCounted();\r
61 //---- check for possible errors\r
62    if(counted_bars<0) return(-1);\r
63 //---- last counted bar will be recounted\r
64    if(counted_bars>0) counted_bars--;\r
65    limit=Bars-counted_bars;\r
66 //---- main loop\r
67    for(int i=0; i<limit; i++)\r
68      {\r
69       //---- ma_shift set to 0 because SetIndexShift called abowe\r
70       ExtBlueBuffer[i]=iMA(NULL,0,JawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);\r
71       ExtRedBuffer[i]=iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);\r
72       ExtLimeBuffer[i]=iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);\r
73      }\r
74 //---- done\r
75    return(0);\r
76   }\r
77 //+------------------------------------------------------------------+\r