-
Notifications
You must be signed in to change notification settings - Fork 1
/
Damiani_Volt.mq4
86 lines (79 loc) · 2.81 KB
/
Damiani_Volt.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#property copyright "Copyright © 2006,2007 Luis Guilherme Damiani"
#property link "http://www.damianifx.com.br"
#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_buffers 3
#property indicator_color1 Silver
#property indicator_color2 Magenta
#property indicator_color3 Lime
extern int Vis_atr = 5;
extern int Vis_std = 8;
extern int Sed_atr = 40;
extern int Sed_std = 100;
extern double Threshold_level = 1.4;
extern bool lag_supressor = TRUE;
double Buff_X = 0.5;
double BufferA[];
double BufferB[];
double BufferC[];
int init() {
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, BufferA);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 4);
SetIndexBuffer(1, BufferB);
SetIndexStyle(2, DRAW_LINE);
SetIndexBuffer(2, BufferC);
return (0);
}
int deinit() {
return (0);
}
int start() {
int countedbar;
double atr;
double Buff_1;
double Buff_2;
double ATR_value;
double std;
double ATD_value;
double T_Level;
double atr_2 = 0;
int countted = IndicatorCounted();
if (countted < 0) return (-1);
if (countted > 0) countted--;
int barcount = Bars - countted;
int atrstd = MathMax(Sed_atr, Sed_std);
if (barcount > atrstd + 5) countedbar = barcount - atrstd;
else countedbar = barcount;
for (int i = countedbar; i >= 0; i--) {
atr = iATR(NULL, 0, Vis_atr, i);
Buff_1 = BufferC[i + 1];
Buff_2 = BufferC[i + 3];
ATR_value = NormalizeDouble(atr, Digits);
if (lag_supressor) atr_2 = atr / iATR(NULL, 0, Sed_atr, i) + Buff_X * (Buff_1 - Buff_2);
else atr_2 = atr / iATR(NULL, 0, Sed_atr, i);
std = iStdDev(NULL, 0, Vis_std, 0, MODE_LWMA, PRICE_TYPICAL, i);
ATD_value = NormalizeDouble(std, Digits);
std /= iStdDev(NULL, 0, Sed_std, 0, MODE_LWMA, PRICE_TYPICAL, i);
T_Level = Threshold_level;
T_Level -= std;
if (i == 0) {
if (atr_2 > T_Level) {
IndicatorShortName("TRADE " + " A(" + DoubleToStr(Vis_atr, 0) + "/" + DoubleToStr(Sed_atr, 0) + ")= " + DoubleToStr(atr_2, 2) + ", " + DoubleToStr(Threshold_level, 1) +
" - S(" + DoubleToStr(Vis_std, 0) + "/" + DoubleToStr(Sed_std, 0) + ")= " + DoubleToStr(T_Level, 2) + " ");
} else {
IndicatorShortName("DO NOT trade " + "A(" + DoubleToStr(Vis_atr, 0) + "/" + DoubleToStr(Sed_atr, 0) + ")= " + DoubleToStr(atr_2, 2) + ", " + DoubleToStr(Threshold_level, 1) +
" - S(" + DoubleToStr(Vis_std, 0) + "/" + DoubleToStr(Sed_std, 0) + ")= " + DoubleToStr(T_Level, 2) + " ");
}
}
if (atr_2 > T_Level) {
BufferC[i] = atr_2;
BufferB[i] = -1;
} else {
BufferC[i] = atr_2;
BufferB[i] = 0.03;
}
BufferA[i] = T_Level;
}
return (0);
}