Forex & EA basics
Orders, deals and positions in MT5: a practical explanation
An order, a deal and a position describe different parts of trading. Using the right term makes logs clearer and prevents a common source of confusion when comparing an EA’s actions with account history.
Follow the transaction through three layers
An order is an instruction. A deal records an execution. A position represents current market exposure. One order can be executed through multiple deals, so order count and deal count need not match. A pending order can exist without having created a position yet.
Read a simple trade sequence
Imagine a pending buy order that later executes, then a separate operation that closes the resulting exposure. The history contains the order lifecycle and execution records; the open-position list shows only what remains open. A partial fill or partial close makes the relationship more detailed, not contradictory.
Check the result after sending
OrderSend returning true does not by itself mean a market trade has completed. Inspect the server return code and follow trade events or history as appropriate. Use order, deal and position identifiers for their intended purposes instead of treating every numeric ticket as interchangeable.
Write useful trade messages
- Record the request type and intended symbol.
- Record the server return code and returned identifiers.
- Connect later execution events to the request.
- Report remaining position volume when monitoring partial closes.
Make it yours with MQLume
MQLume source access helps you follow the complete path from signal to execution handling. Explore Ultimate Breakout System MT5 and study one code path at a time.