Misconception about candle’s timestamp

A common question asked by new users, especially those who are new to trading world as well

According to the dataframe, I got an entry signal at 00.00 UTC. But why the bot only execute the entry at 00.05 UTC? Why was there a lag of one candle?

Their strategy is on 5m timeframe

This question comes up because they have misconception about the timestamp of the candles. They think that the timestamp refers to when that candle closed. So in their mind, the bot should have executed the entry at 00.00 UTC.

In reality, that timestamp refer to the time that particular candle opened. In 5m timeframe, that means the candle closed on 00.05 UTC, which then fetched by the bot, used on indicators calculation, then checked for entry/exit trigger. So the behavior of their bot is correct, and there is no lag or bug.

Detailed illustration on the behavior as follow

  • 00:00:00 UTC : candle A opened
  • 00:05:00 UTC : candle A closed. Candle A will contain OHLCV data and timestamped as 00.00 UTC candle
  • 00:05:01 UTC – Freqtrade fetched data from exchange
  • 00:05:02 UTC – Freqtrade calculate indicators, entry/exit trends, check for entry/exit signals
  • 00:05:03 UTC – Freqtrade enter/exit a trade based of signals

So the next time you see timestamp of a candle, remember that it refer to the time that candle opened. The timestamp of the closing would be according to the timeframe being used.

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *