Skip to content
All library documents

Tracking Trade Operations Through MQL5 Transaction Events

Article MQL5 articles

Summary

This article shows how an MQL5 Expert Advisor can monitor account activity through the OnTradeTransaction event handler. A trade operation may generate several notifications as a request is processed, an order enters or leaves the active list, and deals and history records are updated. The article explains the transaction, request, and result structures, then recommends logging their fields to identify the sequence associated with operations such as opening, modifying, or closing positions and placing pending orders.

The proposed method is empirical: run a diagnostic Expert Advisor, perform trade operations, and inspect the resulting event types and data. The author uses observed call sequences and a counter to distinguish stages, noting that some operations produce several handler calls while position modification produces fewer. These sequences are described as observations rather than universal guarantees, and interpreting events may require checking other request details or stored action state. The approach is useful for event-driven trade management and potentially trade copying, but the article does not evaluate a trading strategy or execution performance.

Key ideas

  • A single trade operation can produce multiple transaction event notifications as its stages complete.
  • The event handler exposes transaction, request, and result data that help identify what happened.
  • Logging event fields while performing representative operations can reveal their observed sequences.
  • A counter and remembered request action can help distinguish pending-order outcomes.

Tags

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