Skip to content
All library documents

MetaTrader 5 Netting and Hedging Positions, Close-By, and Margin

Article MQL5 articles

Summary

The article compares account-level netting and hedging in MetaTrader 5. Under netting, deals on a symbol aggregate into one position: same-direction trades increase volume, while opposite trades reduce, close, or reverse it. Under hedging, trades create separate positions on the same symbol, including positions in opposite directions. The account’s selected mode affects how positions are closed, how reversals work, and how margin is calculated. The article also describes the Close By operation, which pairs opposite positions and can avoid paying the spread on two separate closing transactions.

For hedged accounts, the text outlines broker-selected margin approaches: calculate uncovered and covered volumes in stages, or calculate both directional legs and use the larger margin. It also covers the position tickets and request fields needed to identify positions and close them against one another in MQL5. The examples explain platform mechanics rather than trading performance. Margin rules depend on broker configuration and instrument settings, so the described behavior should be checked against the specific account. Hedging can maintain opposing exposure, but the article does not establish that doing so reduces overall risk or improves returns.

Key ideas

  • Netting consolidates trades on a symbol into one position, while hedging keeps multiple positions separate.
  • Opposite trades reduce, close, or reverse a net position but open separate positions under hedging.
  • Close By pairs opposing positions and can save one spread compared with closing each separately.
  • Hedged margin depends on broker settings and may be based on covered and uncovered volume or the larger directional leg.
  • MQL5 uses position identifiers and additional request fields to manage hedged positions.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.