```
#Previous Lookback Day's Close extended to right edge with option to limit it to show only current day (thisday == 0)
input showtodayonly = no;
input lookback = 2;
#Defines each Day's Bars with zero for current day and +1 for each subsequent day
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);
def thisDay = (HighestAll(dayCount) - dayCount);
#Lookback Day's Close defined and extended to right edge
def closeday = if thisDay == lookback and
GetTime() <= RegularTradingEnd(GetYYYYMMDD())
then close
else closeday[1];
#Lookback Day's Close plotted from that Close to the right edge unless showtodayonly selected, limiting that plot to current day
plot dataclose = if showtodayonly and thisDay > 0
then Double.NaN
else closeday;
dataclose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
dataclose.SetDefaultColor(Color.yellow);
#Lookback Day's Close defined and extended to right edge
def highday = if thisDay == lookback and
GetTime() <= RegularTradingEnd(GetYYYYMMDD())
then high(period=aggregationPeriod.DAY)
else highday[1];
#Lookback Day's High plotted to the right edge unless showtodayonly selected, limiting that plot to current day
plot datahigh = if showtodayonly and thisDay > 0
then Double.NaN
else highday;
datahigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
datahigh.SetDefaultColor(Color.green);
#Lookback Day's Low plotted to the right edge unless showtodayonly selected, limiting that plot to current day
def lowday = if thisDay == lookback and
GetTime() <= RegularTradingEnd(GetYYYYMMDD())
then low(period=aggregationPeriod.DAY)
else lowday[1];
plot datalow = if showtodayonly and thisDay > 0
then Double.NaN
else lowday;
datalow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
datalow.SetDefaultColor(Color.red);
#Lookback Day's Low plotted to the right edge unless showtodayonly selected, limiting that plot to current day
def vwapday = if thisDay == lookback and
GetTime() <= RegularTradingEnd(GetYYYYMMDD())
then reference vwap
else vwapday[1];
plot datavwap = if showtodayonly and thisDay > 0
then Double.NaN
else vwapday;
datavwap.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
datavwap.SetDefaultColor(Color.cyan);
#Bubbles
input showbubbles = yes;
input bubblemover = 2;
def bm = bubblemover;
def bm1 = bm +1;
addchartBubble(showbubbles and isnan(close[bm]) and !isnan(close[bm1]), dataclose[bm], "C"+lookback, dataclose.takeValueColor());
addchartBubble(showbubbles and isnan(close[bm]) and !isnan(close[bm1]), datahigh[bm], "H"+lookback, datahigh.takeValueColor());
addchartBubble(showbubbles and isnan(close[bm]) and !isnan(close[bm1]), datalow[bm], "L"+lookback, datalow.takeValueColor());
addchartBubble(showbubbles and isnan(close[bm]) and !isnan(close[bm1]), datavwap[bm], "VWAP"+lookback, datavwap.takeValueColor());
#
```