Skip to content
All library documents

Handling Trade Events on Netting Accounts in an MQL5 Library

Article MQL5 articles

Summary

This installment explains how an MQL5 trading library can track account events on netting accounts and how their position behavior differs from hedging accounts. A hedging account can hold multiple positions per symbol, while a netting account maintains one. On netting accounts, same-direction orders increase the existing position, and opposite orders can reduce it, close it, or reverse its direction. Position identifiers and tickets can behave differently during these changes, so event handling needs to account for them explicitly.

The implementation separates netting event handling from hedging logic, adjusts event and sorting enumerations, and adds grouping support for related orders and positions. A test Expert Advisor is used to exercise account actions and display resulting events in logs and on the chart. The author reports that the netting test shows a single position and different tickets after a reversal. This is a software-library development article, not a comparison of trading performance; it focuses on event representation and notes that further order-modification and StopLimit tracking work is planned.

Key ideas

  • Netting accounts maintain one position per symbol, while hedging accounts may maintain several.
  • Opposite orders on a netting account can reduce, close, or reverse the existing position.
  • Position IDs and tickets may change or differ during reversals.
  • Separate event-handling paths can clarify account-specific behavior.
  • The test demonstrates event reporting, not strategy performance.

Tags

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