When I add Print(CurrentBars[1]); before the if statement it prints a range of numbers from -1 to 22.
Is there an error in my code or a better way to ensure I get 100 daily bars?
[FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]protected [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]override [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] Initialize()[/FONT]
[FONT=Courier New]{[/FONT]
[FONT=Courier New] BarsRequired = [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]100[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
[FONT=Courier New] Add(PeriodType.Day, [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]);[/FONT]
[FONT=Courier New]}[/FONT]
[FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]protected [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]override [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] OnBarUpdate()[/FONT]
[FONT=Courier New]{[/FONT]
[FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff] if[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] (CurrentBars[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]] < BarsRequired)[/FONT]
[FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff] return[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
[FONT=Courier New] // My code down here requiring 100 bars never executes [/FONT]
[FONT=Courier New] // because [/FONT][FONT=Courier New]the highest value in CurrentBars is 22[/FONT]
[FONT=Courier New]}[/FONT]

Comment