Managing Pending Orders and OCO Limits in Netting Accounts
Summary
The article explains a risk in MetaTrader 5 netting accounts: when a pending order adds to an existing position, the platform updates the position’s average entry price and may also replace its stop-loss and take-profit levels with those attached to the newly filled order. An EA that monitors those limits can then close the enlarged position sooner than intended. The author illustrates the behavior with a buy position followed by a larger pending buy and describes how an existing OCO order can interact with the fill.
The proposed EA changes track whether a position exists and distinguish pending orders that already have limits from simple orders. For eligible simple orders, the EA calculates and displays stop and target levels from configured financial values and order volume; when a position exists, the approach avoids applying OCO limits to new pending orders. The article is specifically concerned with netting behavior. The author reports that account-mode detection failed in testing, so the adjustment may also affect hedging accounts despite the intended distinction.
Key ideas
- In a netting account, filling a pending order can change both the position’s average entry price and its stop and target levels.
- An OCO order attached to a newly filled pending order may overwrite limits already associated with an open position.
- The EA can track whether a position exists and apply limits to eligible pending orders that do not already have them.
- The article warns that its account-mode check behaved incorrectly in testing, leaving uncertainty about hedging-account behavior.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.