Define what close all means on the account
OrdersTotal includes open market orders and pending orders in the trading pool. OrderClose closes an opened market order; pending orders require OrderDelete. Mixing those operations without an explicit rule can remove orders that belong to another strategy.
A production rule should name the symbol scope, magic number, order types, partial-close behavior, slippage in points, and what happens after a rejected close. Manual trades commonly use magic number zero, while an EA should normally own a dedicated number.
| Filter | Why it matters | Example choice |
|---|---|---|
| OrderSymbol | Prevents cross-symbol closure | Current chart symbol only |
| OrderMagicNumber | Separates strategy ownership | Exact EA magic number |
| OrderType | Separates market and pending orders | OP_BUY and OP_SELL only |
| OrderLots | Controls full or partial close | Full selected volume |
