I am trying to draw horizontal lines 1.5 times daily ATR above and below the recent close.
I am getting the error "Error on calling 'OnBarUpdate' method for indicator 'ATROnChart' on bar 72: Bar index needs to be greater/equal 0"
I have added a 1440 min data series in the initiatlize procedure with
Add(PeriodType.Minute, 1440);
Here is what I have in the onbarupdate procedure..
double upperLimit, lowerLimit;
RemoveDrawObject("UpATR");
RemoveDrawObject("DownATR");
if (CurrentBar < 72)
return;
upperLimit=Close[0]+ATR(BarsArray[1], 14)[0]*1.5;
lowerLimit=Close[0]-ATR(BarsArray[1], 14)[0]*1.5;
Print(CurrentBar + ":::" + upperLimit + "::::" + lowerLimit);
DrawLine("UpATR", false, Time[1], upperLimit, Time[1].AddDays(15), upperLimit, Color.Orange, DashStyle.Solid, 1);
DrawLine("DownATR", false, Time[1], lowerLimit, Time[1].AddDays(15), lowerLimit, Color.Orange, DashStyle.Solid, 1);

Comment