Skip to content

Commit

Permalink
Moves enums and structs from Std and MQL5 to appropriate files
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Jan 17, 2022
1 parent af586ee commit f6fb496
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 343 deletions.
88 changes: 0 additions & 88 deletions MQL5.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -307,92 +307,4 @@
#define ERR_USER_ERROR_FIRST 65536 // User defined errors start with this code.
#endif

/**
* MQL5 wrapper to work in MQL4.
*/
class MQL5 {

public:
// Enums.
#ifdef __MQL4__
// 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.
};
// Fill Policy.
enum ENUM_SYMBOL_FILLING {
// @see: https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties
SYMBOL_FILLING_FOK = 1, // A deal can be executed only with the specified volume.
SYMBOL_FILLING_IOC = 2 // Trader agrees to execute a deal with the volume maximally available in the market.
};
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.
};
// 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)
};
#endif

#ifdef __MQL4__
// @see: https://www.mql5.com/en/docs/constants/structures/mqltraderequest
struct MqlTradeRequest {
ENUM_TRADE_REQUEST_ACTIONS action; // Trade operation type.
ulong magic; // Expert Advisor ID (magic number).
ulong order; // Order ticket.
string symbol; // Trade symbol.
double volume; // Requested volume for a deal in lots.
double price; // Price.
double stoplimit; // StopLimit level of the order.
double sl; // Stop Loss level of the order.
double tp; // Take Profit level of the order.
ulong deviation; // Maximal possible deviation from the requested price.
ENUM_ORDER_TYPE type; // Order type.
ENUM_ORDER_TYPE_FILLING type_filling; // Order execution type.
ENUM_ORDER_TYPE_TIME type_time; // Order expiration type.
datetime expiration; // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type.
string comment; // Order comment.
ulong position; // Position ticket.
ulong position_by; // The ticket of an opposite position.
};
// @see: https://www.mql5.com/en/docs/constants/structures/mqltraderesult
struct MqlTradeResult {
uint retcode; // Operation return code.
ulong deal; // Deal ticket, if it is performed.
ulong order; // Order ticket, if it is placed.
double volume; // Deal volume, confirmed by broker.
double price; // Deal price, confirmed by broker.
double bid; // Current Bid price.
double ask; // Current Ask price.
string comment; // Broker comment to operation (by default it is filled by description of trade server return code).
uint request_id; // Request ID set by the terminal during the dispatch.
uint retcode_external; // Return code of an external trading system.
};
#endif
};
#endif // MQL5_MQH
38 changes: 38 additions & 0 deletions Order.enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,33 @@ enum ENUM_ORDER_REASON {
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__
Expand Down Expand Up @@ -294,4 +321,15 @@ 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
35 changes: 35 additions & 0 deletions Order.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,41 @@ struct MqlTradeCheckResult {
double margin_level; // Margin level.
string comment; // Comment to the reply code (description of the error).
};

// @see: https://www.mql5.com/en/docs/constants/structures/mqltraderequest
struct MqlTradeRequest {
ENUM_TRADE_REQUEST_ACTIONS action; // Trade operation type.
ulong magic; // Expert Advisor ID (magic number).
ulong order; // Order ticket.
string symbol; // Trade symbol.
double volume; // Requested volume for a deal in lots.
double price; // Price.
double stoplimit; // StopLimit level of the order.
double sl; // Stop Loss level of the order.
double tp; // Take Profit level of the order.
ulong deviation; // Maximal possible deviation from the requested price.
ENUM_ORDER_TYPE type; // Order type.
ENUM_ORDER_TYPE_FILLING type_filling; // Order execution type.
ENUM_ORDER_TYPE_TIME type_time; // Order expiration type.
datetime expiration; // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type.
string comment; // Order comment.
ulong position; // Position ticket.
ulong position_by; // The ticket of an opposite position.
};

// @see: https://www.mql5.com/en/docs/constants/structures/mqltraderesult
struct MqlTradeResult {
uint retcode; // Operation return code.
ulong deal; // Deal ticket, if it is performed.
ulong order; // Order ticket, if it is placed.
double volume; // Deal volume, confirmed by broker.
double price; // Deal price, confirmed by broker.
double bid; // Current Bid price.
double ask; // Current Ask price.
string comment; // Broker comment to operation (by default it is filled by description of trade server return code).
uint request_id; // Request ID set by the terminal during the dispatch.
uint retcode_external; // Return code of an external trading system.
};
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion Pattern.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

// Includes.
#include "Bar.struct.h"
#include "Pattern.enum.h"
#include "Math.define.h"
#include "Pattern.enum.h"

// Defines structure for bitwise pattern values.
struct PatternBitwise {
Expand Down
Loading

0 comments on commit f6fb496

Please sign in to comment.