Modeling OCO Pending Order Pairs in MQL5
Summary
The article explains one-cancels-the-other orders as a pair of pending orders linked so that triggering either should remove the other. It describes an object-oriented MQL5 design that stores the two order tickets and assigns each pair an identifier. A structure holds each order's properties, including type, volume, price offsets, stop loss, take profit, and expiration settings. The initialization method places the orders and records their tickets; the article also outlines a panel for configuring pairs and notes that trade-event handling is needed to remove the remaining order.
The examples cover combinations of the six pending order types and show test output for a sample pair. The author argues against restricting pairs to one limit and one stop order, allowing more flexible combinations. The panel does not validate field values, so users must check inputs themselves. The text presents implementation mechanics, not evidence of strategy profitability, and emphasizes that the pair must be managed as a linked unit.
Key ideas
- An OCO pair consists of two pending orders, with one intended to be canceled when the other triggers.
- The proposed class stores both order tickets and a unique identifier for each pair.
- Order properties include type, volume, execution and limit offsets, stop loss, take profit, and expiration.
- The example places orders through an initialization method and uses trade-event handling to manage the surviving order.
- The panel leaves input validation to the user, and the article does not evaluate trading performance.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.