AlgoTest Logo

How does AlgoTest define a candle?

Sample candle screenshot

How does AlgoTest define a candle?


We recently received an interesting query from a user, which relates to how does AlgoTest define a candle:

“On Friday ( 24th Feb 2022) Enter Straddle at 9.20 with 40% SL and Re-Enter ASAP 2 times”

AlgoTest trade book

As you can see in the above picture, the CE stop loss is hit at 9:54am, and the CE leg is re-entered with a new strike at 9:54am (since the user has selected Re-enter ASAP) with a new strike price. The new entry price is Rs 617.95.

Now when the user checked the same 9:54am candle on Zerodha, they saw

“But if I look at the Close Price of 36500 CE at 9.54 , its 586.45. Zerodha Close Price – 586.45 Algotest Close Price – 617.95”

zerodha algotest candle image

So why the difference?

In Zerodha, the 9.15am candle refers to the time covering 9:15:00-9:15:59. How does AlgoTest define this candle? In AlgoTest, this timespan refers to the 9.16 candle. So when we say 9:54am, the price you see on AlgoTest was Rs. 617.95, which corresponds to the close price of the 9:53 candle on Zerodha, which was Rs. 620, a lot closer to the price you see on AlgoTest!

Here is the screenshot of the zerodha candle

second candle AlgoTest

Q: Ok, now we know that the 9:19 candle in Zerodha corresponds to the 9:20 candle in AlgoTest. What does that mean for my 9:20 straddle entry?

Answer: Entry at 9:20am on AlgoTest will correspond to 9:19am candle close price on zerodha.

Q: Does this 1-second difference matter?

Answer: If you are trading manually, or using broker API to trade, it doesn’t.

Hopefully, this gives you an idea of how data is represented on AlgoTest. Do check out our website to learn more about options trading in India and how we can improve our trading by backtesting!

3 thoughts on “How does AlgoTest define a candle?”

  1. You say the previous candle close of zerodha chart corresponds to next candle open of algotest chart. But why dont they both match exactly?

    1. So brokers sample data every few seconds and then create the 1-min OHLC candle based on those samples. Since their sampling is not deterministic (eg clocks could be off by a few seconds here and there, different brokers have different hardware, network latency, etc.) , different brokers will have different prices for candles, but it won’t be off by much.

  2. Hi, when I have a stop loss of 0.5% in the underlying points, will you consider the close price of every minute or the high/low of every minute candle?

Leave a Comment

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

Popular Posts