-
Notifications
You must be signed in to change notification settings - Fork 3
/
PhDLib.mqh
171 lines (136 loc) · 6.78 KB
/
PhDLib.mqh
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//+------------------------------------------------------------------+
//| PhDLib.mqh |
//| Copyright © 2018, Copyright 2018, PhD Systems |
//| https://www.phdsystems.co.za |
//+------------------------------------------------------------------+
int CURRENT_TIMEFRAME = 0; // Automatically picks up the TF where it is attached.
int CURRENT_BAR = 0; // The current bar from where to count from when getting the indicator value
string convertTimeToString(int barIndex){
return (string)iTime(Symbol(), CURRENT_TIMEFRAME, barIndex);
}
string convertCurrentTimeToString(){
return (string)iTime(Symbol(), CURRENT_TIMEFRAME, CURRENT_BAR);
}
datetime getCurrentTime(){
return iTime(Symbol(), CURRENT_TIMEFRAME, 0);
}
double getPriceClose(int barIndex) {
return iClose(Symbol(), Period(), barIndex);
}
/**
* This is just to avoid working with numeric directly
*/
int getPastBars(int barIndex){
return (barIndex);
}
int getPreviousBarIndex(int barIndex){
return (barIndex + 1);
}
double getPreviousPriceClose(int barIndex){
return iClose(Symbol(), CURRENT_TIMEFRAME, barIndex);
}
/* START local enums */
enum StochasticsValues {
SIGNAL_VALUE,
STOCHASTIC_VALUE
};
enum Signal {
BUY_SIGNAL,
SELL_SIGNAL,
NO_SIGNAL
};
string getSignalDescription(int signal) {
switch(signal) {
case 0: {
return "BUY_SIGNAL";
}
case 1:{
return "SELL_SIGNAL";
}
}
return "NO_SIGNAL";
}
enum Zones {
BULLISH_ZONE,
BEARISH_ZONE,
BULLISH_EXTREME_ZONE,
BEARISH_EXTREME_ZONE,
RANGING_ZONE,
TRANSITION_ZONE,
NORMAL_ZONE,
UNKNOWN_ZONE
};
string getZoneDescription(int zone) {
switch(zone) {
case 0: {
return "BULLISH_ZONE";
}
case 1:{
return "BEARISH_ZONE";
}
case 2:{
return "BULLISH_EXTREME_ZONE";
}
case 3:{
return "BEARISH_EXTREME_ZONE";
}
case 4:{
return "RANGING_ZONE";
}
case 5:{
return "TRANSITION_ZONE";
}
case 6:{
return "NORMAL_ZONE";
}
case 7:{
return "UNKNOWN_ZONE";
}
}
return "NO_SIGNAL";
}
enum Sentiments {
BULLISH,
BEARISH
};
enum Cross {
BULLISH_CROSS,
BEARISH_CROSS,
NO_CROSS,
UNKNOWN_CROSS,
};
enum Reversal {
BULLISH_REVERSAL,
BEARISH_REVERSAL,
CONTINUATION,
UNKNOWN
};
enum Trend {
BULLISH_TREND,
BEARISH_TREND,
BULLISH_SHORT_TERM_TREND,
BEARISH_SHORT_TERM_TREND,
NO_TREND
};
enum Slope {
BULLISH_SLOPE,
BEARISH_SLOPE,
NEW_BULLISH_SLOPE,
NEW_BEARISH_SLOPE,
BULLISH_CONSOLIDATION_SLOPE,
BEARISH_CONSOLIDATION_SLOPE,
UNKNOWN_SLOPE //This should not happen
};
enum Flatter {
BULLISH_FLATTER,
BEARISH_FLATTER,
NO_FLATTER
};
enum Transition {
BULLISH_TO_BEARISH_TRANSITION,
BEARISH_TO_BULLISH_TRANSITION,
SUDDEN_BULLISH_TO_BEARISH_TRANSITION,
SUDDEN_BEARISH_TO_BULLISH_TRANSITION,
NO_TRANSITION
};
/* END local enums */