-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUtils.mqh
65 lines (56 loc) · 2.54 KB
/
Utils.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
//+------------------------------------------------------------------+
//| Utils.mqh |
//| Copyright 2021, Homma.tech |
//| https://www.homma.tech |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Homma.tech"
#property link "https://www.homma.tech"
#include <Trade/Trade.mqh>
#include "NewTypes.mqh"
#include "Operations.mqh"
class CUtils {
private:
double pastClose;
COperations operations;
public:
double CUtils :: CandleSize(ENUM_TIMEFRAMES u_timeframe = PERIOD_CURRENT, int u_shift = 1);
bool CUtils :: IsCandlePositive(ENUM_TIMEFRAMES u_timeframe = PERIOD_CURRENT, int u_shift = 1);
bool CUtils :: IsCandleNegative(ENUM_TIMEFRAMES u_timeframe = PERIOD_CURRENT, int u_shift = 1);
void CUtils :: ExpertPositions(long magicNumber, ulong &tickets[]);
void CUtils :: ArrayShift(int ut_shift, double &ut_buffer[]);
bool CUtils :: BooleanArray(bool& ut_array[]);
CUtils :: CUtils() {
pastClose = 0;
}
//+------------------------------------------------------------------+
//| Detects a position closed by TP |
//+------------------------------------------------------------------+
bool CUtils :: TPDetector() {
ulong ticket = operations.PastOperationTicket(1);
if(HistoryDealGetInteger(ticket, DEAL_REASON) == DEAL_REASON_TP)
return true;
return false;
}
};
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CUtils :: ArrayShift(int ut_shift,
double &ut_buffer[]) {
if(ut_shift != 0) {
ArraySetAsSeries(ut_buffer, true);
for(int i = ut_shift; i < ArraySize(ut_buffer); i++)
ut_buffer[i - ut_shift] = ut_buffer[i];
}
}
//+------------------------------------------------------------------+
//| Booolean Array verification function |
//+------------------------------------------------------------------+
bool CUtils :: BooleanArray(bool& ut_array[]) {
for(int i = 0; i < ArrayRange(ut_array, 0); i++)
if(ut_array[i] == false)
return false;
return true;
}
//+------------------------------------------------------------------+