I am facing a unique problem. I am trying run backtest and do optimization of parameters for different combinations. For some reason, the code that works in backtest mode doesn't work in optimization mode.
It gives errors when accessing the series data
Indicator 'IchimokuCloud': Error on calling 'OnBarUpdate' method on bar 65: 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.
Specifically it fails in below step
{
if ((CurrentBar < TenkanPeriod) || (CurrentBar < KijunPeriod) || (CurrentBar < ChikouPeriod) )
return;
double fastSum = MAX(High, TenkanPeriod)[0] + MIN(Low, TenkanPeriod)[0];
double mediumSum = MAX(High, KijunPeriod)[0] + MIN(Low, KijunPeriod)[0];
TenkanSen[0] = fastSum / 2.0;
KijunSen[0] = mediumSum / 2.0;
ChikouSpan[KijunPeriod] = Close[0];
SenkouSpanA[0] = (TenkanSen[0] + KijunSen[0]) / 2.0;
SenkouSpanB[0] = (MAX(High, ChikouPeriod)[0] + MIN(Low, ChikouPeriod)[0]) / 2.0;
}
Is anyone else facing this issue?
Comment