Today is 3/1/24.
Yesterday was 2/29/24 (leap day).
My strategy ran no issues all day yesterday, but suddenly sometime during the new trading day (today), the strategy disabled & refuses to start with the following error:
"Error on Calling 'OnbarUpdate' method on bar #: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."
I was able to find the offending code by doing a bunch of prints. After commenting out the line starting with "myBarsAgo", the strategy no longer errors out.
if ( ToTime(Time[0]) >= 00000 && ToTime(Time[0]) < 93000 ) { myBarsAgo = CurrentBar - Bars.GetBar(new DateTime(Time[0].Year, Time[0].Month, Time[0].Day-1, 18, 00, 00)); // fetch BarsAgo# for 6pm EST myOpenLevel = Open[myBarsAgo]; }
I can't wrap my head around as to why this is an issue, anyone have any ideas?
Thanks!
Comment