-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCandleInfos.mqh
74 lines (60 loc) · 3.16 KB
/
CandleInfos.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
//+------------------------------------------------------------------+
//| CandleInfos.mqh |
//| Copyright 2022, Homma.tech |
//| https://www.homma.tech |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Homma.tech"
#property link "https://www.homma.tech"
#include "NewTypes.mqh"
class CCandleInfos {
private:
double pastClose;
public:
CCandleInfos :: CCandleInfos();
double CCandleInfos :: CandleSize (ENUM_TIMEFRAMES u_timeframe = PERIOD_CURRENT,
int u_shift = 1);
bool CCandleInfos :: IsCandlePositive (ENUM_TIMEFRAMES u_timeframe = PERIOD_CURRENT,
int u_shift = 1);
bool CCandleInfos :: IsCandleNegative (ENUM_TIMEFRAMES u_timeframe = PERIOD_CURRENT,
int u_shift = 1);
bool CCandleInfos :: IsNewCandle(ENUM_TIMEFRAMES timeframe = 0);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CCandleInfos :: CCandleInfos() {
pastClose = 0;
}
//+------------------------------------------------------------------+
//| Candle size function |
//+------------------------------------------------------------------+
double CCandleInfos :: CandleSize (ENUM_TIMEFRAMES u_timeframe = PERIOD_CURRENT,
int u_shift = 1) {
return MathAbs(iOpen(_Symbol, u_timeframe, u_shift) - iClose(_Symbol, u_timeframe, u_shift));
}
//+------------------------------------------------------------------+
//| Is candle positive function |
//+------------------------------------------------------------------+
bool CCandleInfos :: IsCandlePositive (ENUM_TIMEFRAMES u_timeframe = PERIOD_CURRENT,
int u_shift = 1) {
return iOpen(_Symbol, u_timeframe, u_shift) < iClose(_Symbol, u_timeframe, u_shift);
}
//+------------------------------------------------------------------+
//| Is candle negative function |
//+------------------------------------------------------------------+
bool CCandleInfos :: IsCandleNegative (ENUM_TIMEFRAMES u_timeframe = PERIOD_CURRENT,
int u_shift = 1) {
return iOpen(_Symbol, u_timeframe, u_shift) > iClose(_Symbol, u_timeframe, u_shift);
}
//+------------------------------------------------------------------+
//| Is new candle function |
//+------------------------------------------------------------------+
bool CCandleInfos :: IsNewCandle(ENUM_TIMEFRAMES timeframe = 0) {
if(pastClose != iClose(NULL, timeframe, 1)) {
pastClose = iClose(NULL, timeframe, 1);
return true;
}
pastClose = iClose(NULL, timeframe, 1);
return false;
}
//+------------------------------------------------------------------+