I'm wondering if anybody else can spot the problem with my code here, I've been pulling my hair out for hours trying to figure out what the hell is wrong....
The error I get is
"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."
In my "initialise" I have the below to check if there is enough data:
if (CurrentBar < barsCheck)
{
return;
}
And I have narrowed the problem down to this section of code:
private void MergeLastXBars()
{
myHigh = 0;
myLow = 10;
myOpen = (double)opens[(barsCheck - 1)];
myClose = (double)closes[0];
for (int i = (barsCheck -1); i > 0; i--)
{
if ((double)highs[i] > myHigh)
{
myHigh = (double)highs[i];
}
Print ("Checking bar " + i);
}
for (int j = (barsCheck -1); j > 0; j--)
{
if ((double)lows[j] < myLow)
{
myLow = (double)lows[j];
}
}
}
I can't for the life of me figure out what's doing it...
Any help would be much appreciated.
Thanks!
Bill

Comment