I keep getting bands above all of the bars. I only want the previous days bar to be where the plot begins and goes across the chart to the end of following day.
Code:
# Half ATR Bands
input length = 14;
def atrValue = ATR(length);
def halfAtr = atrValue / 2;
def prevClose = close(period = AggregationPeriod.DAY)[1];
def ATR_High = if !IsNaN(prevClose) then prevClose + halfAtr else Double.NaN;
def ATR_Low = if !IsNaN(prevClose) then prevClose - halfAtr else Double.NaN;
plot UpperLine = CompoundValue(1, ATR_High, ATR_High);
UpperLine.SetLineWeight(2);
UpperLine.SetDefaultColor(Color.green);
plot LowerLine = CompoundValue(1, ATR_Low, ATR_Low);
LowerLine.SetLineWeight(2);
LowerLine.SetDefaultColor(Color.red);