-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathOrder.enum.h
338 lines (314 loc) · 13.9 KB
/
Order.enum.h
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2021, EA31337 Ltd |
//| https://github.com/EA31337 |
//+------------------------------------------------------------------+
/*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* @file
* Includes Order's enums.
*/
#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once
#endif
/* Order actions. */
enum ENUM_ORDER_ACTION {
ORDER_ACTION_CLOSE = 1, // Close the order.
ORDER_ACTION_COND_CLOSE_ADD, // Add close condition.
ORDER_ACTION_OPEN, // Open the order.
FINAL_ORDER_ACTION_ENTRY
};
/* Order conditions. */
enum ENUM_ORDER_CONDITION {
ORDER_COND_NONE = 0, // Empty condition.
ORDER_COND_IN_LOSS, // When order in loss
ORDER_COND_IN_PROFIT, // When order in profit
ORDER_COND_IS_CLOSED, // When order is closed
ORDER_COND_IS_OPEN, // When order is open
ORDER_COND_LIFETIME_GT_ARG, // Order lifetime greater than argument value.
ORDER_COND_LIFETIME_LT_ARG, // Order lifetime lesser than argument value.
ORDER_COND_PROP_EQ_ARG, // Order property equals argument value.
ORDER_COND_PROP_GT_ARG, // Order property greater than argument value.
ORDER_COND_PROP_LT_ARG, // Order property lesser than argument value.
FINAL_ORDER_CONDITION_ENTRY
};
// Defines enumeration for order properties.
enum ENUM_ORDER_PARAM {
ORDER_PARAM_NONE = 0, // None.
ORDER_PARAM_COLOR_ARROW, // Color of the opening arrow on the chart.
ORDER_PARAM_COND_CLOSE, // Close condition.
ORDER_PARAM_COND_CLOSE_ARG_VALUE, // Close condition arguments.
ORDER_PARAM_COND_CLOSE_NUM, // Number of close conditions.
ORDER_PARAM_DUMMY, // Whether order is dummy.
ORDER_PARAM_REFRESH_FREQ, // How often to refresh order values (in secs).
ORDER_PARAM_UPDATE_FREQ, // How often to update order stops (in secs).
FINAL_ENUM_ORDER_PARAM
};
/**
* A variety of custom properties for reading order values.
*/
enum ENUM_ORDER_PROPERTY_CUSTOM {
ORDER_PROP_NONE = 0,
ORDER_PROP_COMMISSION, // Commission.
ORDER_PROP_LAST_ERROR, // Last error code.
ORDER_PROP_PRICE_CLOSE, // Close price.
ORDER_PROP_PRICE_OPEN, // Open price.
ORDER_PROP_PRICE_STOPLIMIT, // The limit order price for the StopLimit order.
ORDER_PROP_PROFIT, // Current profit in price difference.
ORDER_PROP_PROFIT_PIPS, // Current profit in pips.
ORDER_PROP_PROFIT_TOTAL, // Total profit (profit minus fees).
ORDER_PROP_PROFIT_VALUE, // Total profit in base currency value.
ORDER_PROP_REASON_CLOSE, // Reason or source for closing an order.
ORDER_PROP_TICKET, // Ticket number.
ORDER_PROP_TIME_CLOSED, // Closed time.
ORDER_PROP_TIME_OPENED, // Opened time.
ORDER_PROP_TIME_LAST_REFRESH, // Last refresh of the order values.
ORDER_PROP_TIME_LAST_UPDATE, // Last update of the order values.
ORDER_PROP_TOTAL_FEES, // Total fees.
};
// Defines enumeration for order close reasons.
enum ENUM_ORDER_REASON_CLOSE {
ORDER_REASON_CLOSED_ALL = 0, // Closed all
ORDER_REASON_CLOSED_BY_ACTION, // Closed by action
ORDER_REASON_CLOSED_BY_EXPIRE, // Closed by expiration
ORDER_REASON_CLOSED_BY_OPPOSITE, // Closed by opposite order
ORDER_REASON_CLOSED_BY_SIGNAL, // Closed by signal
ORDER_REASON_CLOSED_BY_SL, // Closed by stop loss
ORDER_REASON_CLOSED_BY_TEST, // Closed by test
ORDER_REASON_CLOSED_BY_TP, // Closed by take profit
ORDER_REASON_CLOSED_BY_USER, // Closed by user
ORDER_REASON_CLOSED_UNKNOWN, // Closed by unknown event
};
#ifndef __MQL5__
/* Defines the reason for order placing. */
enum ENUM_ORDER_REASON {
ORDER_REASON_CLIENT, // The order was placed from a desktop terminal.
ORDER_REASON_EXPERT, // The order was placed from an MQL5-program (e.g. by an EA or a script).
ORDER_REASON_MOBILE, // The order was placed from a mobile application.
ORDER_REASON_SL, // The order was placed as a result of Stop Loss activation.
ORDER_REASON_SO, // The order was placed as a result of the Stop Out event.
ORDER_REASON_TP, // The order was placed as a result of Take Profit activation.
ORDER_REASON_WEB, // The order was placed from a web platform.
};
// An order status that describes its state.
enum ENUM_ORDER_STATE {
ORDER_STATE_STARTED, // Order checked, but not yet accepted by broker
ORDER_STATE_PLACED, // Order accepted
ORDER_STATE_CANCELED, // Order canceled by client
ORDER_STATE_PARTIAL, // Order partially executed
ORDER_STATE_FILLED, // Order fully executed
ORDER_STATE_REJECTED, // Order rejected
ORDER_STATE_EXPIRED, // Order expired
ORDER_STATE_REQUEST_ADD, // Order is being registered (placing to the trading system)
ORDER_STATE_REQUEST_MODIFY, // Order is being modified (changing its parameters)
ORDER_STATE_REQUEST_CANCEL // Order is being deleted (deleting from the trading system)
};
enum ENUM_ORDER_TYPE_FILLING {
// @see: https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties
ORDER_FILLING_FOK, // An order can be filled only in the specified amount.
ORDER_FILLING_IOC, // A trader agrees to execute a deal with the volume maximally available in the market.
ORDER_FILLING_RETURN // In case of partial filling a market or limit order with remaining volume is not canceled but
// processed further.
};
enum ENUM_ORDER_TYPE_TIME {
// @see: https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties
ORDER_TIME_GTC, // Good till cancel order.
ORDER_TIME_DAY, // Good till current trade day order.
ORDER_TIME_SPECIFIED, // Good till expired order.
ORDER_TIME_SPECIFIED_DAY // The order will be effective till 23:59:59 of the specified day.
};
#endif
#ifndef __MQ4__
/**
* Enumeration for order selection type.
*
* Notes:
* - Enum has sense only in MQL5 and C++.
*/
enum ENUM_ORDER_SELECT_TYPE {
ORDER_SELECT_TYPE_NONE,
ORDER_SELECT_TYPE_ACTIVE,
ORDER_SELECT_TYPE_HISTORY,
ORDER_SELECT_TYPE_DEAL,
ORDER_SELECT_TYPE_POSITION
};
/**
* Enumeration for order data type.
*
* Notes:
* - Enums has sense only in MQL5.
*/
enum ENUM_ORDER_SELECT_DATA_TYPE {
ORDER_SELECT_DATA_TYPE_INTEGER,
ORDER_SELECT_DATA_TYPE_DOUBLE,
ORDER_SELECT_DATA_TYPE_STRING
};
#endif
#ifndef __MQL__
/**
* Enumeration for OrderGetDouble() and HistoryOrderGetDouble().
*
* @see: https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties
*/
enum ENUM_ORDER_PROPERTY_DOUBLE {
ORDER_VOLUME_INITIAL, // Order initial volume.
ORDER_VOLUME_CURRENT, // Order current volume.
ORDER_PRICE_OPEN, // Price specified in the order.
ORDER_SL, // Stop Loss value.
ORDER_TP, // Take Profit value.
ORDER_PRICE_CURRENT, // The current price of the order symbol.
ORDER_PRICE_STOPLIMIT // The Limit order price for the StopLimit order.
};
/**
* A variety of properties for reading order values.
* Enumeration for OrderGetInteger() and HistoryOrderGetInteger().
*
* @see: https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties
*/
enum ENUM_ORDER_PROPERTY_INTEGER {
ORDER_TICKET, // Order ticket. Unique number assigned to each order.
ORDER_TIME_SETUP, // Order setup time.
ORDER_TYPE, // Order type.
ORDER_STATE, // Order state.
ORDER_TIME_EXPIRATION, // Order expiration time.
ORDER_TIME_DONE, // Order execution or cancellation time.
ORDER_TIME_SETUP_MSC, // The time of placing an order for execution in milliseconds since 01.01.1970.
ORDER_TIME_DONE_MSC, // Order execution/cancellation time in milliseconds since 01.01.1970.
ORDER_TYPE_FILLING, // Order filling type.
ORDER_TYPE_TIME, // Order lifetime.
ORDER_MAGIC, // ID of an Expert Advisor that has placed the order.
ORDER_REASON, // The reason or source for placing an order.
ORDER_POSITION_ID, // Position identifier that is set to an order as soon as it is executed.
ORDER_POSITION_BY_ID // Identifier of an opposite position used for closing by order ORDER_TYPE_CLOSE_BY.
};
/**
* A variety of properties for reading order values.
* Enumeration for OrderGetString() and HistoryOrderGetString().
*
* @see: https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties
*/
enum ENUM_ORDER_PROPERTY_STRING {
ORDER_COMMENT, // Order comment.
ORDER_EXTERNAL_ID, // Order identifier in an external trading system (on the Exchange).
ORDER_SYMBOL, // Symbol of the order.
};
#endif
/* Defines modes for order type values (Take Profit and Stop Loss). */
enum ENUM_ORDER_TYPE_VALUE { ORDER_TYPE_TP = ORDER_TP, ORDER_TYPE_SL = ORDER_SL };
#ifndef __MQL__
/**
* Order operation type.
*
* @see: https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties
*/
enum ENUM_ORDER_TYPE {
ORDER_TYPE_BUY, // Market Buy order.
ORDER_TYPE_SELL, // Market Sell order.
ORDER_TYPE_BUY_LIMIT, // Buy Limit pending order.
ORDER_TYPE_SELL_LIMIT, // Sell Limit pending order.
ORDER_TYPE_BUY_STOP, // Buy Stop pending order
ORDER_TYPE_SELL_STOP, // Sell Stop pending order.
ORDER_TYPE_BUY_STOP_LIMIT, // Upon reaching the order price, a pending Buy Limit order is placed at the StopLimit
// price.
ORDER_TYPE_SELL_STOP_LIMIT, // Upon reaching the order price, a pending Sell Limit order is placed at the StopLimit
// price.
ORDER_TYPE_CLOSE_BY, // Order to close a position by an opposite one.
ORDER_TYPE_UNSET // A NULL value.
};
#else
#define ORDER_TYPE_UNSET NULL
#endif
/* Positions */
#ifndef __MQL5__
/**
* Returns double type of the position property.
*
* @see:
* - https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties
*/
enum ENUM_POSITION_PROPERTY_DOUBLE {
POSITION_PRICE_CURRENT, // Current price of the position symbol (double).
POSITION_PRICE_OPEN, // Position open price (double).
POSITION_PROFIT, // Current profit (double).
POSITION_SL, // Stop Loss level of opened position (double).
POSITION_SWAP, // Cumulative swap (double).
POSITION_TP, // Take Profit level of opened position (double).
POSITION_VOLUME, // Position volume (double).
};
//#define POSITION_TICKET
/**
* Returns integer type of the position property.
*
* @see:
* - https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties
*/
enum ENUM_POSITION_PROPERTY_INTEGER {
POSITION_IDENTIFIER, // A unique number assigned to each re-opened position (long).
POSITION_MAGIC, // Position magic number (see ORDER_MAGIC) (long).
POSITION_REASON, // The reason for opening a position (ENUM_POSITION_REASON).
POSITION_TICKET, // Unique number assigned to each newly opened position (long).
POSITION_TIME, // Position open time (datetime).
POSITION_TIME_MSC, // Position opening time in milliseconds since 01.01.1970 (long).
POSITION_TIME_UPDATE, // Position changing time (datetime).
POSITION_TIME_UPDATE_MSC, // Position changing time in milliseconds since 01.01.1970 (long).
POSITION_TYPE, // Position type (ENUM_POSITION_TYPE).
};
/**
* Returns string type of the position property.
*
* @see:
* - https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties
*/
enum ENUM_POSITION_PROPERTY_STRING {
POSITION_COMMENT, // Position comment (string).
POSITION_EXTERNAL_ID, // Position identifier in an external trading system (on the Exchange) (string).
POSITION_SYMBOL, // Symbol of the position (string).
};
/**
* Returns reason for opening a position.
*
* @see:
* - https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties
*/
enum ENUM_POSITION_REASON {
POSITION_REASON_CLIENT, // Order placed from a desktop terminal.
POSITION_REASON_EXPERT, // Order placed from an Expert.
POSITION_REASON_MOBILE, // Order placed from a mobile application.
POSITION_REASON_WEB, // Order placed from the web platform.
};
/**
* Direction of an open position (buy or sell).
*
* @see:
* - https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties
*/
enum ENUM_POSITION_TYPE {
POSITION_TYPE_BUY, // Buy position.
POSITION_TYPE_SELL // Sell position.
};
// Trading operations.
enum ENUM_TRADE_REQUEST_ACTIONS {
// @see: https://www.mql5.com/en/docs/constants/tradingconstants/enum_trade_request_actions
TRADE_ACTION_DEAL, // Place a trade order for an immediate execution with the specified parameters (market order).
TRADE_ACTION_PENDING, // Place a trade order for the execution under specified conditions (pending order).
TRADE_ACTION_SLTP, // Modify Stop Loss and Take Profit values of an opened position.
TRADE_ACTION_MODIFY, // Modify the parameters of the order placed previously.
TRADE_ACTION_REMOVE, // Delete the pending order placed previously.
TRADE_ACTION_CLOSE_BY // Close a position by an opposite one.
};
#endif