If I turn on the for statement I get the error
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.
//GIVEN: nMar****pen, nMarketClose
//TASK: gets the overnight range of the market
//RETURN: high and low of the overnight range
public void getFibanacciRangeTimes()
{
Print(Bars.Count);
// if(Bars.Count > 100)
// {
int nDayStart = Bars.GetBar(dMar****pen.AddMinutes(-30));
int nDayEndIndex1 = Bars.GetBar(dMarketClose.AddDays(-1));
Print("Day start index " + nDayStart);
Print("Day end index " + nDayEndIndex1);
Print(Bars.Count + "Bars coutn");
if(Bars.Count > nDayStart)
{
for(int nTempCount = nDayEndIndex1; nTempCount < nDayStart; nTempCount = nTempCount + 1)
{
if (dFibHigh < High[nTempCount])
dFibHigh = High[nTempCount];
if (dFibLow > Low[nTempCount])
dFibLow = Low[nTempCount];
}
}
Print("Fib High is " + dFibHigh);
Print("Fib Low is " + dFibLow);
}
Comment