Skip to content
All library documents

Displaying Bar Countdown Time in a Trading Replay System

Article MQL5 articles

Summary

This installment of a MetaTrader replay-system series addresses showing the time remaining until the next bar. The author first documents a platform problem: changing a chart timeframe during replay can cause the platform to lose contact with ticks or bars in a custom asset. The suggested workaround is to set the intended timeframe before loading the replay session.

The article tests adding tick timestamps to custom rates so an indicator can read seconds, but reports that this disrupts chart content despite providing the desired time information. It then describes a different synchronization method: have the service use the platform’s one-minute bar start time and compare it with the current replay time, adjusted for the replay clock, to calculate the countdown. This avoids sending frequent custom events from the service to the indicator. The approach is presented as suitable for the current version, not a definitive design; the author expects a more robust solution may be needed, and platform behavior could change.

Key ideas

  • Set the chart timeframe before loading replay because changing it may disconnect the custom asset from its ticks or bars.
  • Adding seconds to custom-rate timestamps can expose time to an indicator but may also corrupt chart display.
  • The countdown can be derived from the one-minute bar start time and the replay clock.
  • Using the service to obtain timing information avoids repeatedly firing custom events from an indicator.
  • The proposed countdown method is provisional and depends on platform behavior.

Tags

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