I think there may be a possible bug with DateTime when I try to set a DateTime object to a time before the chart begins.
My chart session begins and ends at 12:00:00 am, I'm trading FX.
My code is this:
DateTime today = new DateTime(Time[0].Ticks);
DateTime yesterday = new DateTime();
yesterday = today.AddDays(-1);
DateTime openingBell = new DateTime(yesterday.Year, yesterday.Month, yesterday.Day, 16, 0, 0);
barsAgo = GetBar(openingBell);
when backtesting, I Print("Opening Bell was at " + + Time[barsAgo].ToString() ); and I get 12:00:00, not 16:00:00 on the previous day.
Comment