Skip to content
All library documents

Tracking StopLimit Activation and Order or Position Changes in MQL5

Article MQL5 articles

Summary

This installment extends a cross-platform MetaTrader library for tracking account events. Its central example is StopLimit activation: because the activation is not recorded in account history as a distinct event, the library detects a change in the type of an active order while its ticket remains the same. The same framework is prepared to track changes to pending-order prices and protective levels, as well as position StopLoss and TakeProfit levels.

The approach keeps a snapshot of monitored properties alongside their current values, compares the two, and creates records containing both old and new states when a difference appears. A separate collection of changed objects is then processed in a loop, so multiple changes detected in one tick are not lost. The article describes extending the account event system and outlines a tester procedure, but the provided excerpt gives no measured performance evidence. It implements StopLimit activation tracking here; the other property-change events are groundwork for later work.

Key ideas

  • StopLimit activation can be detected by watching an active order whose type changes while its ticket stays the same.
  • The account history does not expose this activation as a distinct event in the described setup.
  • A prior-state snapshot enables detection of changes in monitored order and position properties.
  • Buffering changed objects in a collection lets the event handler process several changes from one tick.
  • The article implements StopLimit activation tracking and prepares the framework for additional modifications.

Tags

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