r/metatrader • u/AlgoTraderTools • 5h ago
Information OrderSend works in the MT5 tester and returns 10030 live: filling modes are per-symbol properties
If your EA fills orders in the Strategy Tester and then gets rejected on a live account with retcode 10030 (TRADE_RETCODE_INVALID_FILL) — often only on one broker, while the same EA runs fine on another — the cause is almost never your entry logic. It's SYMBOL_FILLING_MODE.
Every MT5 symbol advertises which order filling policies its trade server accepts, as a bitmask:
SYMBOL_FILLING_FOK(1) — Fill or Kill: the whole order at once or nothing.SYMBOL_FILLING_IOC(2) — Immediate or Cancel: fill what is available now, cancel the rest.(
SYMBOL_FILLING_BOC, bit 4, exists on newer builds for exchange-style books.)
Your MqlTradeRequest.type_filling must be one of the policies the symbol actually advertises. If it isn't, OrderSend comes back with 10030, and nothing about the order is invalid except its filling field.
Why the tester hides it: the tester is far more forgiving about the filling field than a real trade server — a request with a policy the tester doesn't enforce still goes through. So an EA that hardcodes type_filling = ORDER_FILLING_FOK builds a clean backtest history and only meets the constraint when the request reaches a live server that enforces its symbol's flags. Broker A allows FOK everywhere, broker B advertises IOC only, and the same EA is "broken" on B. Bonus trap: pending orders on several broker symbols only accept ORDER_FILLING_RETURN, so the same EA can fill market orders fine and then reject every pending order.
Three things worth doing before any live deployment:
Read
SYMBOL_FILLING_MODEat init and log it. Pick the request's filling policy from the flags — prefer FOK if the bit is set, else IOC, elseORDER_FILLING_RETURN— instead of hardcoding one policy.If you use
CTrade, callSetTypeFillingBySymbol(_Symbol)instead of leaving the default. The defaulttype_fillinginCTradeis FOK, which is exactly the value that trips 10030 on IOC-only symbols.Treat
OrderSendrejections as data. Log the retcode together with the symbol's filling-mode bits — after a few days of logs you know the real per-symbol acceptance matrix instead of assuming it.
The general pattern is the same as for stop levels: the tester validates your logic against price data, but the order envelope (filling policy, execution mode, deviation) is negotiated against a real trade server with per-symbol rules. If your EA sends hardcoded request fields, it doesn't have one strategy — it has one per broker, and only one of them is ever tested.