Strategy Specs:
BarsInProgress == 0: 3 minutes
BarsInProgress == 1: 6 minutes
Trading in realtime allows for BarsSinceNewTradingDay to supply a proper result because it updates on each tick. Backtesting is a problem because the BarsSinceNewTradingDay counter only updates "on bar close".
The bulk of my strategy calculates in BarsInProgress == 0. Since BarsSinceNewTradingDay does not allow it to reference other BarsArray, I have it called in BarsInProgress == 1 to get the result.
The issue is every other 3 min. bar references the wrong 6 min. BarsSinceNewTradingDay when backtesting. (Calculate.OnBarClose)
My initial thought is to define which bars need correction and apply a fix for each bar. The basic structure is below. The question is: How do I extract the BarsInProgress == 0 "minute timestamp" to allow for a correction to be applied?
if (BarsInProgress == 1) { if (!State.Realtime && [COLOR=#FF0000][B]Times[0][0] “minute timestamp“ is: 03 || 09 || 15 || 21 || 27 || 33 || 39 || 45 || 51 || 57[/B][/COLOR]) { BarSaved = BarsSinceNewTradingDay + 1; } }
Thanks in advance!
Comment