-
Notifications
You must be signed in to change notification settings - Fork 2
/
Positions.mqh
66 lines (57 loc) · 2.45 KB
/
Positions.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
//+------------------------------------------------------------------+
//| Positions.mqh |
//| Copyright 2022, Homma.tech |
//| https://www.homma.tech |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Homma.tech"
#property link "https://www.homma.tech"
#property version "1.00"
#include "Operations.mqh"
class CPositions : public COperations {
private:
public:
void CPositions :: ExpertPositions (long magicNumber,
ulong &dest_tickets[]);
void CPositions :: CloseAllPositions(string symbol, int deviation);
CPositions();
~CPositions();
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
CPositions::CPositions() {
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
CPositions::~CPositions() {
}
//+------------------------------------------------------------------+
//| Expert positions function |
//+------------------------------------------------------------------+
void CPositions :: ExpertPositions (long magicNumber,
ulong &dest_tickets[]) {
ulong ticket;
ArrayFree(dest_tickets);
for(int i = 0; i < PositionsTotal(); i++) {
ticket = PositionGetTicket(i);
PositionSelectByTicket(ticket);
if(PositionGetInteger(POSITION_MAGIC) == magicNumber)
ArrayResize(dest_tickets, i + 1);
dest_tickets[i] = ticket;
}
}
//+------------------------------------------------------------------+
//| Close all positions function |
//+------------------------------------------------------------------+
void CPositions :: CloseAllPositions(string symbol, int deviation) {
CTrade trade_TL;
ulong ticket = 0;
if(PositionSelect(symbol)) {
for(int i = 0; i < PositionsTotal(); i++) {
ticket = PositionGetTicket(i);
trade_TL.PositionClose(ticket, deviation);
}
}
}
//+------------------------------------------------------------------+