Inconsistency in live OHLC data

Aman_0309
I am using an algorithm for trading that requires 5 minute OHLC data as soon as every 5 minute period get completed.
So, my code tries to fetch latest 5 minute OHLC data just 1 or 2 seconds after completion of recent 5 minute time period (e.g. at time 9:40:01 my code tries to fetch OHLC data related to the candle that built between 9:35:00 to 9:40:00).
Most of the time I get correct OHLC data related to recently created 5 minute candle.
But, few times it happens that I get:
  • OHLC data related to 5 minute candle that created just previous to latest completed candle
  • OHLC data having same value for Open, High, Low, Close and it is equal to Close price related to second latest competed candle
Above problem happens randomly for few times.
So, my question is that how much minimum time I should wait for getting correct value of latest 5 minute OHLC data?
Also, is there any thing I am required to mention in the code to get correct OHLC data as soon as 5 minute time period get over?
Sign In or Register to comment.