I am trying to capture the current candle's High and Low and compare that with current day's open price.
My buy condition : If Open = Low and current High crosses Previous days High or Previous week's high then Buy.
Pasting the code below, which is giving me completely wrong backtested result. Any suggestion to fix this would be greatly appreciated.
@C_M thanks for your quick reply, I am looking for a 15 min periodicity, and challenge I am facing while checking the Open price is low till that candle.
Regardless of time frame, you can only run an accurate exploration when the bar is complete. The only exception is when you want to query the open price, which will remian fixed until the bar is complete. Use 'code check' to see if there's a look-ahead bias.
If you're using your exploration to trade and want to estimate the close and enter at or near close, that's ok in my book. But on a small timeframe like 15 minutes, you may need to add several ticks to your backtest Buyprice for a reasonable estimate of performance (one component of 'slippage'). The contract needs to be liquid at the time you want to trade it.
For really accurate backtesting on smaller time frames you probably need millisecond price and depth data.