Fixing Replay Pauses and Pointer Leaks in a MetaTrader Simulator
Summary
This article investigates unexpected pauses in a MetaTrader replay simulator. The service had been reading a control button’s chart-object state, which could change after a custom chart event and falsely signal a pause. The author replaces that polling approach with reads from the control indicator’s buffer, accepting some additional read cost while preparing for a fast-forward feature. The article also recommends a tooltip property as a possible way to inspect chart-object data when needed.
A second debugging example concerns a memory leak: a mouse event repeatedly created a drawing object without releasing the previous pointer target. The article traces the accumulation to a missing check and explains why pointer reassignment and lifecycle management need care in MQL5. These are implementation lessons for replay and simulation software, not evidence about a trading strategy. The discussion reflects behavior observed at the time of writing, and the source is truncated, so some implementation context is unavailable.
Key ideas
- A chart event can unexpectedly alter an object state and make a replay service infer a false pause.
- Reading control data from an indicator buffer avoids relying on the affected object property.
- The author selects buffer reads partly to support a planned fast-forward feature.
- Repeatedly creating an object without managing the prior pointer can cause memory to accumulate.
- Pointer use and object lifecycle need explicit checks in MQL5 programs.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.