declare upper;
input ATR_Lookback = 30;
input ATR_Multiplier = 0.50;
def ATR_day = MovingAverage(AverageType.WILDERS, TrueRange(high(period = AggregationPeriod.DAY), close(period = AggregationPeriod.DAY), low(period = AggregationPeriod.DAY)), ATR_Lookback);
def opening = if secondsFromTime(0930) >= 0 and secondsFromTime(0930)[1] < 0 then open else opening[1];
plot day_open = opening;
plot day_minus_one_atr_lower = opening - (ATR_Day * ATR_Multiplier);
plot day_plus_one_atr_higher = opening + (ATR_Day * ATR_Multiplier);
day_open.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
day_minus_one_atr_lower.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
day_plus_one_atr_higher.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
day_open.SetDefaultColor(color.gray);
day_minus_one_atr_lower.SetDefaultColor(color.red);
day_plus_one_atr_higher.SetDefaultColor(color.green);
AddVerticalLine(secondsFromTime(1000) == 0, "half-hour mark", color.plum);
plot exceeded_upward = if close crosses above day_plus_one_atr_higher then low else double.nan;
plot exceeded_downward = if close crosses below day_minus_one_atr_lower then high else double.nan;
exceeded_upward.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
exceeded_upward.SetDefaultColor(color.green);
exceeded_downward.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
exceeded_downward.SetDefaultColor(color.red);