I am trying to draw horizontal lines 1.5 ATR above and below the close of the last bar on the chart. The issue is that I am able to draw the lines with respect to the second last bar on the chart but not the las bar on the chart. Here is the code I am using and a chart screenshot of the issue. you can see that the center of the lines is the close of last bar minus one and not the last bar.
The data I am using is an offline EOD data that I manually upload at the end of each trading day.
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
double upperLimit, lowerLimit;
if (CurrentBar==Bars.Count-2)
{
upperLimit=Close[0]+ATR(aTRPeriod)[0]*aTRMultiplier;
lowerLimit=Close[0]-ATR(aTRPeriod)[0]*aTRMultiplier;
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