Below is a snippet of the piece of code in question:
OnStateChange()
{
Calculate = Calculate.OnBarClose
}
OnBarUpdate()
{
if (CurrentBars[0] < 1)
return
if (Bars.IsFirstBarOfSession)
{
Print (string.Format("{0}-, {1}", Times[0][0], Bars.BarsSinceNewTradingDay));
}
}
When I run it in a backtest, the print returns twice, say I run it from 1/03/2023 - 1/05/2023, the prints will read:
1/3/2023 4:00:00 PM-0
1/3/2023 5:30:00 PM-22
1/4/2023 4:00:00 PM-0
1/4/2023 5:30:00 PM-22
1/5/2023 4:00:00 PM-0
1/5/2023 5:30:00 PM-22
it will print twice, once when the market closes at 4:00 pm and then when it opens at 5:30 pm. Why would it be printing on the last bar of the session as 0 and printing "22" on the real first bar of the session?

Comment