-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAdvanced_ADX.mq4
66 lines (65 loc) · 2.15 KB
/
Advanced_ADX.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
//+------------------------------------------------------------------+
//| Advanced_ADX.mq4 |
//| Copyright © 2006, Eng. Waddah Attar |
//| waddahattar@hotmail.com |
//+------------------------------------------------------------------+
#property copyright "Waddah Attar"
#property link "waddahattar@hotmail.com"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//----
extern int ADXPeriod = 13;
//----
double ExtBuffer1[];
double ExtBuffer2[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0, ExtBuffer1);
SetIndexStyle(0, DRAW_HISTOGRAM, 0, 2);
//----
SetIndexBuffer(1, ExtBuffer2);
SetIndexStyle(1, DRAW_HISTOGRAM, 0, 2);
//----
IndicatorShortName("Advanced_ADX (" + ADXPeriod + ")");
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int i, limit;
double ADX0,ADX1,ADX2;
int counted_bars = IndicatorCounted();
if(counted_bars < 0)
return(-1);
if(counted_bars > 0)
counted_bars--;
limit = Bars - counted_bars;
//----
for(i = 0; i < limit ; i++)
{
ADX0 = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_MAIN, i);
ADX1 = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_PLUSDI, i);
ADX2 = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_MINUSDI, i);
//----
if(ADX1 >= ADX2)
{
ExtBuffer1[i] = ADX0;
ExtBuffer2[i] = 0;
}
else
{
ExtBuffer1[i] = 0;
ExtBuffer2[i] = ADX0;
}
}
return(0);
}
//+------------------------------------------------------------------+