Add Fazzaco to desktop

Add Fazzaco to desktop

Access Fazzaco from desktop next time

Add now
English

MetaQuotes: How MT5 Connects Orders, Positions and Margin

Source: Fazzaco

MetaQuotes develops MetaTrader 5, a trading platform that combines client terminals with the servers and administrative tools used by brokers. Its relevance to an FX business extends well beyond charts: the platform determines how instructions become executions, how executions alter positions, and how those positions enter margin calculations. Those distinctions explain why two accounts displaying the same MT5 interface can behave differently.

MetaQuotes supplies the software; it does not provide brokerage or investment services. Its broker materials describe support for FX, equities and futures, desktop, mobile and web access, and connections to external trading systems. The broker still defines the actual account and instrument settings. A platform feature list therefore needs to be read alongside the rules of the account being offered.

The broker controls the operating environment

MetaQuotes describes MT5 as software deployed on the operator's own infrastructure, rather than a vendor-operated SaaS service. Its published deployment model puts server administration and support under the operator's control. That makes infrastructure ownership part of the product decision, alongside the terminal experience and trading functions.

The back office supports distinct permissions for administrators, dealers, accountants and risk managers. Trading conditions include contract specifications, margin requirements, trading sessions, swaps, commissions, spreads and markups. Different client groups can be handled within the same platform environment. For an operations team, a change to a contract or account group is consequently a business-rule change, not merely a cosmetic adjustment to the client screen.

This distinction also matters when investigating an incident. A client-facing order message, a dealer decision and an external execution record answer different questions. Access to a management interface does not, by itself, explain which component rejected an instruction or which rule was applied.

An order, a deal and a position are different records

In MT5 terminology, an order expresses an instruction; a deal records an execution; a position represents the resulting holding or obligation. One order can produce several deals. Counting deal records as though each were a separate client instruction can therefore distort operational reporting.

The platform links these records through tickets. Deals identify their originating order and associated position, while successive deals can explain how a position increased or was partially closed. Operations sent to an exchange or liquidity provider can also carry identifiers from that external system. These links give a reconciliation process a route from the client's request to the resulting exposure.

Consider a hypothetical request to buy three lots that executes in two parts: one lot and then two lots. There is one instruction, two execution records and a position outcome determined by the account's accounting method and any existing holding. A support response should reconstruct that chain before treating the extra execution record as a duplicate order.

MT5 order, deal and position ticket relationships

MetaQuotes documentation: tickets connect orders, executions and positions.

Netting and hedging change what an opposite trade does

MT5 supports both netting and hedging accounts. Netting keeps one position per symbol, whereas hedging permits separate positions, including simultaneous long and short holdings. MetaQuotes' programming documentation distinguishes OTC netting, exchange netting and retail hedging through the account's margin-mode property. Developers can inspect that property instead of assuming that every MT5 account uses the same model.

For illustration, assume an account holds a two-lot long position and then executes a fresh one-lot sell instruction in the same symbol. Under netting, the holding becomes one lot long. Under hedging, an ordinary new sell opens a separate one-lot short alongside the existing long. Closing a particular hedging position requires a position-closing operation; simply placing an opposite new trade is a different action.

The net directional quantity in this example is one lot in either case, but the stored positions are different. That difference affects position selection, reporting and the inputs to margin calculations. A broker's customer instructions and an automated strategy's position-management logic need to agree on which model the account actually uses.

Partial execution depends on the filling policy

Execution mode and filling policy address different aspects of an order. MT5 distinguishes Instant, Request, Market and Exchange execution. A filling policy governs what happens when the requested quantity cannot all be executed. The MQL5 symbol reference documents the permitted combinations and the server settings that apply.

Fill or Kill requires the full requested quantity, which may be assembled from several available offers. Immediate or Cancel allows available quantity to execute and cancels the remainder. Return keeps an unfilled remainder in processing, but it is unavailable for immediate execution under Market Execution. Pending orders have their own rule: the documentation specifies Return when submitting them, regardless of the execution mode, because execution is deferred.

In a simplified example, a five-lot immediate request faces only three executable lots. Subject to the applicable market and settings, IOC can leave three lots executed and two canceled; FOK requires all five or no execution. These outcomes are different by design. A connector that assumes every successful request was filled completely can misstate the position before any price-risk calculation begins.

Opposite positions do not automatically mean zero margin

MetaQuotes' margin documentation describes two approaches to opposing positions in a hedging account, selected by the broker. The basic method separates uncovered volume, covered volume and pending orders. Covered volume can itself attract margin according to the instrument's hedged-margin settings.

The alternative calculates the long and short sides, including the relevant pending orders, and uses the larger resulting margin requirement. This is a comparison of calculated requirements, not simply a choice of whichever side has more lots. Instrument formulas, rates and currency conversion can matter.

Equal long and short quantities therefore do not establish the amount of margin reserved. Nor does the word “hedging” establish that a client position has been offset with an external counterparty. Account position accounting, margin treatment and the broker's external risk transfer are separate layers. Keeping them separate makes both client explanations and internal exposure reports more precise.

Closing positions and connecting the back office

On hedging accounts, Close By can offset two opposite positions in the same symbol. If their sizes differ, the residual follows the direction of the larger position. The documentation describes two “out by” deals, with the combined profit or loss recorded on one of them. A reporting integration needs to recognize that representation rather than interpret the other record in isolation.

Bulk closing also needs result-level monitoring. MT5 first attempts opposite-position closures on hedging accounts, then handles remaining positions. An error during the paired-closing stage stops that process; later individual closure requests can also fail and leave positions open. Clicking a group command is therefore not evidence that every holding has disappeared.

MetaQuotes exposes separate APIs for these surrounding workflows: Manager API for administration utilities, Gateway API for other trading systems and custom feeds, Web API for web services, and Report API for server reports. Their roles help distinguish an account-management integration from an execution connection. For a broker adopting MT5, the useful operating model ties those interfaces back to the same order, deal, position and margin records, so that the client terminal and the back office describe the same events.

Create Company Page