Skip to content
All library documents

Improving Timing and Efficiency in a Market Replay Simulator

Article MQL5 articles

Summary

This installment revises an MQL5 market replay service to make one-minute bar construction more consistent and efficient. The earlier approach could take longer than a minute to build bars, particularly during volatile periods, creating a misleading impression about how easily fast price moves could be traded. The updated design moves most behavior into a replay class, simplifies the service interface, and coordinates replay state through chart and terminal global variables.

The central loop measures elapsed tick intervals, accumulates delays, updates the replay position, and sleeps to pace playback. It also allows bar construction and timing metrics to be displayed. The article stresses that these changes address replay control and processing efficiency, not the fidelity of simulated randomness: the author says the random-walk model and its problems will be handled later. The presented material is a development step, and visual inspection alone is not sufficient to establish that generated market movement is statistically realistic.

Key ideas

  • The earlier replay method could build one-minute bars too slowly during volatile periods and distort the apparent pace of trading.
  • The revised service delegates replay behavior to a class and reduces work in the service loop.
  • Replay pacing uses tick-time differences, accumulated delay, playback state, and timed sleeps.
  • The system can expose bar construction and timing metrics for inspection.
  • More efficient replay does not establish realistic random market behavior; that modeling work is deferred.

Tags

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