Skip to content
All library documents

Detecting New Candle Opens in an OnTick Handler

Article MQL5 code base

Summary

This brief note describes detecting when a new candle begins on a selected chart timeframe. The check is intended to run inside an OnTick handler, so code can respond once per bar instead of repeating an action on every incoming tick. The timeframe is configurable; the example uses the current chart timeframe as its default.

The document identifies practical uses such as triggering a one-time operation, placing a trade, or calling another function at the start of a bar. It gives no implementation code, benchmark, or trading results, so it explains the purpose and configuration at a high level rather than specifying a complete detection method. It also does not discuss handling missed ticks, multiple timeframes, or execution risks. The page includes unrelated promotional and policy text, which adds no trading guidance.

Key ideas

  • A new candle check can be placed in an OnTick handler.
  • The timeframe to monitor can be selected, with the current chart timeframe as the default.
  • A bar-open event can trigger an action once per candle rather than on every tick.
  • The note gives no code or performance evidence for a specific implementation.

Tags

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