I have an indicator making calculation in 1 min Heiken Ashi, however, i want to add Range (4) data
When i do this i get error
Indicator '': Error on calling 'OnBarUpdate' method on bar 0: 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 have done different things, i added
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade || CurrentBar < BarsRequiredToPlot || CurrentBars[0] < 1 || CurrentBars[1] < 1 || CurrentBars[2] < 1)
return;
OnBarUpdate() will be called on incoming tick events on all Bars objects added to the strategy
We only want to process events on our primary Bars object (index = 0) which is set when adding
the strategy to a chart
if (BarsInProgress != 0)
return;
.
.
.
. rest of code
how do i prevent this error? can you help?
Thanks

Comment