input daysback = 1;
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) ;
def poc = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no) else poc[1];
def vahigh = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VAHigh else vahigh[1];
def valow = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VALow else valow[1];
plot poc1 = if thisDay > daysback then Double.NaN else poc;
plot vahigh1 = if thisDay > daysback then Double.NaN else vahigh;
plot valow1 = if thisDay > daysback then Double.NaN else valow;
poc1.SetDefaultColor(Color.CYAN);
vahigh1.SetDefaultColor(Color.YELLOW);
valow1.SetDefaultColor(Color.YELLOW);
input bubblemover = 3;
def b = bubblemover;
def b1 = b + 1;
input showbubbles = yes;
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), poc1[b], "POC - " + daysback, Color.CYAN);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), vahigh1[b], "VAH - " + daysback, Color.YELLOW);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), valow1[b], "VAL - " + daysback, Color.YELLOW, no);