Skip to main content

Understanding 'Candle IDs' – A Superpower for Strategy Building

Candle ID lets you reference specific past or current candles in your strategy, unlocking precise and advanced trading logic.

Updated over 2 months ago

Purpose
Candle ID is a simple but powerful way to reference past or current candlesticks in your trading logic. Once you understand it, you can precisely tell your bot which candle’s data to use — opening the door to more advanced strategies.

The Concept

Every candlestick on a chart is assigned a number called its Candle ID:

  • Candle ID 0 – The current, still-forming candle.

  • Candle ID 1 – The most recently closed candle.

  • Candle ID 2 – The candle before that, and so on.

Think of it as counting candles backwards in time from the present moment.


Example on a Daily Time Frame

  • Candle ID 0 – Today’s candle, still moving as the market updates.

  • Candle ID 1 – Yesterday’s candle (fully closed).

  • Candle ID 2 – The day before yesterday’s candle.


Example on a 1-Hour Time Frame

Let’s say it’s 14:37 (market time):

  • Candle ID 0 – The 14:00–15:00 candle, still forming.

  • Candle ID 1 – The 13:00–14:00 candle (closed).

  • Candle ID 5 – The 09:00–10:00 candle earlier today.


Why It’s Powerful

By changing the Candle ID, you can:

  • Check conditions from past candles (e.g., “Was the high of Candle ID 5 higher than today’s high?”).

  • Build multi-candle logic (e.g., “If the last three candles closed higher than they opened…”).

  • Combine with indicators to reference past signals instead of only the current candle.


Pro Tip

When running backtests or applying your bot to a chart, remember:

  • Candle ID 0 changes every market tick — it’s not fixed until the candle closes.

  • For stable conditions, use Candle ID 1 or higher to avoid signals changing mid-candle.

Did this answer your question?