-
Notifications
You must be signed in to change notification settings - Fork 1
/
Bulls.mq4
67 lines (66 loc) · 2.46 KB
/
Bulls.mq4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//+------------------------------------------------------------------+
//| Bulls.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Bulls Power"
#property strict
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Silver
//--- input parameter
input int InpBullsPeriod=13;
//--- buffers
double ExtBullsBuffer[];
double ExtTempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
string short_name;
//--- 1 additional buffer used for counting.
IndicatorBuffers(2);
IndicatorDigits(Digits);
//--- indicator line
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtBullsBuffer);
SetIndexBuffer(1,ExtTempBuffer);
//--- name for DataWindow and indicator subwindow label
short_name="Bulls("+IntegerToString(InpBullsPeriod)+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
}
//+------------------------------------------------------------------+
//| Bulls Power |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int limit=rates_total-prev_calculated;
//---
if(rates_total<=InpBullsPeriod)
return(0);
//---
if(prev_calculated>0)
limit++;
for(int i=0; i<limit; i++)
{
ExtTempBuffer[i]=iMA(NULL,0,InpBullsPeriod,0,MODE_EMA,PRICE_CLOSE,i);
ExtBullsBuffer[i]=high[i]-ExtTempBuffer[i];
}
//---
return(rates_total);
}
//+------------------------------------------------------------------+