Sending Chart and Indicator Changes as Custom MQL5 Events
Summary
This article describes adding event tracking to a chart-object collection in an MQL5 library. It defines event types for chart opening and closing, indicator subwindow changes, and adding, removing, or changing indicators. When the library detects one of these changes, it sends a custom event to a controlling program chart, which can then handle the event and report details such as the chart, window, or indicator involved.
A practical challenge is identifying a subwindow or indicator after deletion. The implementation addresses this by retaining removed chart objects, windows, and indicators in lists and adding a window-index property to indicator objects. The article also explains a limitation: if several chart elements are changed programmatically during one timer tick, event detection may be ambiguous or may capture only the last change. Its examples show journal messages for common manual chart edits, but it does not benchmark the library or discuss how these events affect trading decisions or performance.
Key ideas
- The library sends custom events when charts, indicator windows, or indicators are added, removed, or changed.
- A controller can inspect event codes and react to chart changes reported by the collection.
- Retaining removed objects makes their details available after deletion, including an indicator's former window index.
- Multiple programmatic changes within one timer tick can make event detection unreliable.
- The examples demonstrate event reporting for manual chart operations, not trading performance.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.