MQL5 Strategy Engine Support for Pending Orders and Hedging
Summary
This article describes changes to a reusable MQL5 strategy engine to support pending orders and hedging accounts. It adds methods for retrieving normalized Ask, Bid, and Last prices for the strategy’s working symbol, plus an overridden Digits method to avoid using the chart symbol’s precision when the working symbol differs. For hedging accounts, positions are rebuilt and selected by ticket, allowing multiple positions on a symbol to be represented and managed separately; netting accounts retain symbol-based selection.
The article also introduces dedicated order-environment and pending-order classes to manage order references and operations, with strategy initialization methods for Buy Stop, Buy Limit, Sell Stop, and Sell Limit orders. A sample impulse strategy is discussed across account types, but the supplied text does not include its full rules or comparative performance results. The focus is on engine architecture and account compatibility. It emphasizes that the framework supplies position and order handling, while each strategy must define logic appropriate to whether it manages one position or several.
Key ideas
- Convenience methods return normalized Ask, Bid, and Last prices for the strategy’s working symbol.
- The strategy engine selects positions by symbol on netting accounts and by ticket on hedging accounts.
- Separate pending-order classes provide a structured way to access and manage active orders.
- Strategy initialization methods distinguish pending buy orders from pending sell orders.
- The engine supports different account models, while strategy logic must handle multiple positions when needed.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.