Locking a Market Replay Indicator to Its Intended Chart
Summary
This article explains how to restrict a MetaTrader 5 market replay control indicator to the replay symbol and a single intended chart. It first checks the chart symbol during indicator initialization, removes the indicator when the symbol is wrong, and handles deinitialization carefully so that removing the indicator does not close an unrelated chart. It then describes coordinating the indicator with a replay service through shared state and chart identification, with a chart template used to place the indicator because a service cannot add one in the same way as a script.
The discussion includes example MQL5 fragments and a template setting whose adjustment resolves the reported locking issue. It also compares script and service behavior and explains why preventing attachment to the wrong symbol alone does not stop duplicate indicators. The method is specific to this replay application and platform behavior; the author notes that the implementation changed during development and does not claim a universal or ideal locking solution.
Key ideas
- Check the chart symbol during indicator initialization and remove the indicator if it is not the replay symbol.
- Handle the removal event so that rejecting an indicator does not accidentally close its chart.
- Use shared state and chart identification to coordinate the indicator with the replay service.
- A chart template can attach the indicator where a service cannot add it directly.
- Symbol checks alone do not prevent duplicate instances on the replay chart.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.