bleh
[mqlkit.git] / indicators / Bulls.mq4
blobf226c11cdeadd26fa72efac72c2e23203872516e
1 //+------------------------------------------------------------------+\r
2 //|                                                        Bulls.mq4 |\r
3 //|                      Copyright © 2005, MetaQuotes Software Corp. |\r
4 //|                                       http://www.metaquotes.net/ |\r
5 //+------------------------------------------------------------------+\r
6 #property copyright "Copyright © 2005, MetaQuotes Software Corp."\r
7 #property link      "http://www.metaquotes.net/"\r
8 \r
9 #property indicator_separate_window\r
10 #property indicator_buffers 1\r
11 #property indicator_color1 Silver\r
12 //---- input parameters\r
13 extern int BullsPeriod=13;\r
14 //---- buffers\r
15 double BullsBuffer[];\r
16 double TempBuffer[];\r
17 //+------------------------------------------------------------------+\r
18 //| Custom indicator initialization function                         |\r
19 //+------------------------------------------------------------------+\r
20 int init()\r
21   {\r
22    string short_name;\r
23 //---- 1 additional buffer used for counting.\r
24    IndicatorBuffers(2);\r
25    IndicatorDigits(Digits);\r
26 //---- indicator line\r
27    SetIndexStyle(0,DRAW_HISTOGRAM);\r
28    SetIndexBuffer(0,BullsBuffer);\r
29    SetIndexBuffer(1,TempBuffer);\r
30 //---- name for DataWindow and indicator subwindow label\r
31    short_name="Bulls("+BullsPeriod+")";\r
32    IndicatorShortName(short_name);\r
33    SetIndexLabel(0,short_name);\r
34 //----\r
35    return(0);\r
36   }\r
37 //+------------------------------------------------------------------+\r
38 //| Bulls Power                                                      |\r
39 //+------------------------------------------------------------------+\r
40 int start()\r
41   {\r
42    int i,counted_bars=IndicatorCounted();\r
43 //----\r
44    if(Bars<=BullsPeriod) return(0);\r
45 //----\r
46    int limit=Bars-counted_bars;\r
47    if(counted_bars>0) limit++;\r
48    for(i=0; i<limit; i++)\r
49       TempBuffer[i]=iMA(NULL,0,BullsPeriod,0,MODE_EMA,PRICE_CLOSE,i);\r
50 //----\r
51    i=Bars-counted_bars-1;\r
52    while(i>=0)\r
53      {\r
54       BullsBuffer[i]=High[i]-TempBuffer[i];\r
55       i--;\r
56      }\r
57 //----\r
58    return(0);\r
59   }\r
60 //+------------------------------------------------------------------+