after days that I'm breaking my head to solve a problem I decided to play the help from home.
I'm developing an indicator Nt7 that works on the 30min time frame and I need to develop some calculations using the LinReg calculated on the closing of the previous day but on the 1 DAY time frame.
I stated this in the Initialize:
protected override void Initialize()
{
Add(PeriodType.Day, 1); //dataseries1
}
& this in the OnBarUpdate:
protected override void OnBarUpdate()
{
if (CurrentBars[1]==0&&BarsPeriod.Id == PeriodType.Day && BarsPeriod.Value >= 21)
{
double LinRegValue = LinReg(BarsArray[1], 18)[0];
}
}
But this code with the start of the market replay continues to generate errors of this type:
Error on calling 'OnBarUpdate' method for indicator 'IndicatorsLinReg' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
thanks for a support
Chris
Comment