
An Expert Advisor can send a trade request without waiting for the trade server to finish processing it. That speed is useful when a strategy monitors several instruments, but it separates the moment an instruction is dispatched from the moment an account actually changes. A successful function call is not evidence that a position exists.
In meta trader 5, asynchronous execution through OrderSendAsync() or the CTrade asynchronous mode makes trade-event handling central to automated risk control. Five distinct failure points arise when an EA mistakes a submitted instruction for a completed transaction.
Dispatch Confirmation Can Be Mistaken for Execution
OrderSendAsync() returns after a request has been sent for processing, rather than waiting for its final execution outcome. A successful return and an initial TRADE_RETCODE_PLACED response do not guarantee a fill. The server may subsequently reject the request or execute it under the applicable order rules.
An EA that immediately marks the position as open can calculate its next trade from imaginary exposure. The program needs a pending-request state until subsequent trade transactions establish what happened.
Trade Events Can Arrive in an Unexpected Sequence
OnTradeTransaction() reports changes involving requests, orders, deals and positions. One instruction can produce several notifications, and their arrival order is not guaranteed to follow the neat sequence a developer might draw on paper. Transaction processing can also continue while the EA handles earlier events.
Matching events solely by symbol risks confusing simultaneous instructions. Where available, request identifiers help correlate the request response; order and deal tickets then identify subsequent records. The handler should reconcile actual server records rather than infer completion from the first notification.
Partial Execution Can Leave Risk Below the Intended Hedge
Imagine a hypothetical EA attempting to hedge a long position in an industrial-metals index CFD by selling four contracts, each worth $20 per index point. The asynchronous request is accepted for processing, but only one contract fills initially at 1,250. The remaining three contracts have not executed.
If the index falls to 1,238 before any further fill, the executed hedge gains $240, rather than the $960 that four filled contracts would have gained. The $720 difference is missing hedge protection, not slippage on the completed contract. Treating a request for four contracts as four completed contracts obscures the actual exposure. The EA must track filled volume and any outstanding remainder before adjusting the hedge.
Repeated Signals Can Queue More Exposure Than Margin Allows
A fast strategy may receive another signal while the first asynchronous request is unresolved. Sending another order because no position appears yet can create overlapping requests. Even if each submission passes local checks, aggregate exposure may exceed the strategy’s limit when several requests execute.
For meta trader 5 systems, a reservation ledger can count pending requested volume alongside filled positions. It should release that reservation only after confirmed rejection, cancellation or reconciliation with executed volume. Waiting for the server is not always the safest solution: indiscriminate blocking can delay unrelated exit decisions while the market moves.
Slow Event Handlers Can Lose Critical Transaction Detail
The terminal maintains a finite queue of trade transactions for an EA. If OnTradeTransaction() performs lengthy calculations or network-dependent work, incoming transactions can supersede older queued entries. Missing an event can leave internal state inconsistent even when the broker’s account records are correct.
Keep event handlers short, persist essential identifiers and periodically reconcile positions, active orders and trade history. Before opening a CFD position with an asynchronous EA, test rejected, partially filled and overlapping requests on a demo account, then verify that the program’s recorded exposure always matches the terminal’s actual orders and positions.