How MetaTrader 5 Represents Orders, Deals, Positions, and History
Summary
The article explains MetaTrader 5’s trading records and how they relate: an order is a request to trade, a deal is an execution that may partially fill an order, and a position represents the resulting exposure in an instrument. It describes how orders can remain pending or move into history, while deals are recorded as completed events. Position volume and direction change as deals are applied. The platform’s described position model allows one open position per symbol and account.
It also explains how the terminal synchronizes account history with the server and how MQL5 programs access trading data through their own caches rather than directly querying the terminal database. Programs must select or request the relevant orders, deals, positions, or history before reading properties, and should refresh data when needed. The article gives function-oriented examples and warns that empty or stale caches can lead to incorrect decisions. These details are platform-specific guidance for building reliable trading software, not a strategy or performance analysis.
Key ideas
- An order is a trade request, a deal records execution, and a position represents current exposure.
- A single order may result in multiple deals, such as when execution is partial.
- The terminal synchronizes account history with the server and stores it locally.
- MQL5 programs read trading data through caches populated by selection and history-request functions.
- Programs should check that cache data is available and current before relying on it.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.