#Price levels after specific bar v1
#Modified to work on charts whether extended hours are displayed or not
input bars = 15;
input ORBegin = 0930;
#Thisday snippet
def ymd = GetYYYYMMDD();
def candles = !IsNaN(close);
def capture = candles and ymd != ymd[1];
def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0);
#Identifies each day with visible bars starting with #1
def thisDay = (HighestAll(dayCount) - dayCount) + 1 ;
def endbn = if SecondsFromTime(ORBegin) == 0 then BarNumber() + bars - 1 else endbn[1];
def endh = if Between(BarNumber(), endbn - bars , endbn) then Highest(high, bars ) else endh[1];
def endl = if Between(BarNumber(), endbn - bars , endbn ) then Lowest(low, bars ) else endl[1];
#Plot of highs/lows (endh/endl) based upon the first x bars input, projected after those first x bars
plot hafter_endbn = if thisDay == 1 and SecondsFromTime(ORBegin) >= 0 and BarNumber() > endbn then endh else Double.NaN;
plot lafter_endbn = if thisDay == 1 and SecondsFromTime(ORBegin) >= 0 and BarNumber() > endbn then endl else Double.NaN;
hafter_endbn.SetDefaultColor(Color.CYAN);
lafter_endbn.SetDefaultColor(Color.CYAN);
#Offset ([-bars]) of endh/endl to backfill those plots over the first x bars
plot h_after_offset = if thisDay == 1 and SecondsFromTime(ORBegin) >= 0 and BarNumber() <= endbn then endh[-bars] else Double.NaN;
plot l_after_offset = if thisDay == 1 and SecondsFromTime(ORBegin) >= 0 and BarNumber() <= endbn then endl[-bars] else Double.NaN;
h_after_offset.SetPaintingStrategy(PaintingStrategy.DASHES);
h_after_offset.SetDefaultColor(Color.WHITE);
l_after_offset.SetPaintingStrategy(PaintingStrategy.DASHES);
l_after_offset.SetDefaultColor(Color.WHITE);
input test = yes;
AddChartBubble(test and BarNumber() <= endbn, endl[-bars], thisDay + " \n" + endh + " \n" + endl, if low == endl[-bars] then Color.WHITE else if high == endh[-bars] then Color.YELLOW else if BarNumber() == endbn[-bars] then Color.MAGENTA else Color.GRAY, no);