- Expert Advisors main event: OnTick
- Basic principles and concepts: order, deal, and position
- Types of trading operations
- Order types
- Order execution modes by price and volume
- Pending order expiration dates
- Margin calculation for a future order: OrderCalcMargin
- Estimating the profit of a trading operation: OrderCalcProfit
- MqlTradeRequest structure
- MqlTradeCheckResult structure
- Request validation: OrderCheck
- Request sending result: MqlTradeResult structure
- Sending a trade request: OrderSend and OrderSendAsync
- Buying and selling operations
- Modying Stop Loss and/or Take Profit levels of a position
- Trailing stop
- Closing a position: full and partial
- Closing opposite positions: fill and partial
- Placing a pending order
- Modifying a pending order
- Deleting a pending order
- Getting a list of active orders
- Order properties (active and historical)
- Functions for reading properties of active orders
- Selecting orders by properties
- Getting the list of positions
- Position properties
- Functions for reading position properties
- Deal properties
- Selecting orders and deals from history
- Functions for reading order properties from history
- Functions for reading deal properties from history
- Types of trading transactions
- OnTradeTransaction event
- Synchronous and asynchronous requests
- OnTrade event
- Monitoring trading environment changes
- Creating multi-symbol Expert Advisors
- Limitations and benefits of Expert Advisors
- Creating Expert Advisors in the MQL Wizard
Pending order expiration dates
For pending orders, an important characteristic is their expiration mode. In the MQL5 API, the order validity period can be set in the type_time field of the special MqlTradeRequest structure when sending a trade request via the OrderSend function. Acceptable values are described in the ENUM_ORDER_TYPE_TIME enumeration.
Identifier (Value) |
Description |
---|---|
ORDER_TIME_GTC (0) |
The order will be in the queue until it is canceled |
ORDER_TIME_DAY (1) |
The order will be valid only during the current trading day |
ORDER_TIME_SPECIFIED (2) |
The order will be valid until the expiration date |
ORDER_TIME_SPECIFIED_DAY (3) |
The order will be valid until 23:59:59 of the specified day (if this time does not fall within the trading session, the expiration will occur at the nearest next trading time) |
It should be noted that each financial instrument has two properties SYMBOL_EXPIRATION_MODE and SYMBOL_ORDER_GTC_MODE, which determine Pending order expiration rules for this instrument. When forming an order, an MQL program can choose one of the allowed modes. We will consider an example after studying the OrderSend function.