MetaTrader, EAs & VPS

Orders, deals & positions in MT5: not the same thing

In MT5, "order", "deal" and "position" are three different objects, not three words for the same thing. Traders coming from MT4 conflate them, then wonder why their trade count is wrong, their history doesn't reconcile and their EA counts the same trade twice. Getting the data model right is the difference between reporting that adds up and reporting that quietly lies.

Three objects, three lifetimes

MT5 separates the intent to trade, the event of trading, and the result of trading:

  • Order — an instruction to buy or sell: a market order, or a pending order like a buy limit. An order is a request. It lives until it executes, expires or is cancelled. It is not a trade yet.
  • Deal — the execution of an order: the actual fill that moves money. A deal is a historical fact and never changes once written. One order can produce several deals if it fills in parts.
  • Position — your current net exposure in a symbol, built and modified by deals. A position is a running state: it opens, changes volume, and eventually closes to zero.
Orders are intent, deals are events, positions are state. An order becomes one or more deals; deals accumulate into a position; the position is what you actually hold right now.

Why MT4 habits break here

MT4 had one concept — the "order" — that blurred all three. Opening a trade, the open trade itself, and the closed record all lived under OrderSelect. MT5 pulls them apart, and crucially it is netting or hedging depending on account type. On a netting account you hold at most one position per symbol; a second buy adds to it rather than opening a parallel trade. On a hedging account each entry can be its own position, closer to MT4's feel. Code that assumes "one ticket = one trade" is correct on MT4 and wrong on netting MT5.

A worked trade

Suppose you place a market buy of 1.0 lot EURUSD on a netting account:

  1. You submit an order (buy, 1.0 lot).
  2. Liquidity is thin, so it fills as two deals: 0.6 lot at 1.08500 and 0.4 lot at 1.08505. The order is now done.
  3. Those two deals build one position: long 1.0 lot at a volume-weighted 1.08502.
  4. Later you sell 0.4 lot. That is a new order, producing one deal, which reduces the same position to 0.6 lot — it does not open a second short position.
  5. Finally you close the remaining 0.6 lot. One more order, one more deal, and the position ceases to exist. Its full story now lives as a chain of deals in history.

Count "trades" by orders and you'd say three. Count by deals and you'd say four. Count by positions and it was one round-turn. All three are legitimate — but only if you know which you are counting.

Where this bites in practice

  • Double-counting on partial fills. An EA that treats every deal as a separate entry inflates its position count and can breach its own max-trades limit on a single partial fill.
  • Reconciling profit. Profit and swap land on deals, not on the position or the order. Sum the wrong object and your P&L won't match the broker statement.
  • Netting surprises. A hedging strategy ported unchanged onto a netting account silently merges its "two opposite trades" into one net position, and the hedge you thought you had never existed.
  • Pending orders that never became deals. A cancelled or expired pending order is a real order in history with zero deals — count orders as trades and you'll book phantom activity.
  • Position tickets are reused conceptually. On netting, the position ticket persists as volume changes, so "did this position open today?" needs the opening deal's time, not the position's current state.

How to think about your history

When you reconcile an account, drive everything from deals — they are immutable, timestamped, and carry the money. Reconstruct positions by walking deals in order per symbol and magic number; treat orders as the audit trail of intent, useful for spotting rejections and cancellations but never as your trade ledger. If your reporting and your broker's statement disagree, it is almost always because one side counted orders or positions where the other counted deals.

Takeaway

Order, deal and position are intent, event and state — related but never interchangeable. Decide deliberately which one a given count, limit or report should be based on, know whether your account nets or hedges, and build your P&L from deals. Do that and MT5's history reconciles cleanly; skip it and you'll spend hours chasing numbers that were never measuring the same thing.

← MetaTrader, EAs & VPS
Tecnemia AlgoSentinel

One panel for the whole operation

AlgoSentinel runs your whole EA operation — it watches your strategies and your VPS around the clock and flags what needs attention.

  • EA Incubation Control — a clear verdict: incubate · promote · retire
  • VPS & Live Monitor — the alert that saves money when an EA fails to start
See AlgoSentinel →
AlgoSentinel dashboard (real view)