#VolumeProfle
input daysback = 0;
input showontodayonly = yes;
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];
input extend_plot = yes;
def p1 = if extend_plot and IsNaN(close) then p1[1]
else if thisDay > daysback or
showontodayonly and GetDay() != GetLastDay()
then Double.NaN
else poc;
plot poc1 = p1;
def vh1 = if extend_plot and IsNaN(close) then vh1[1]
else if thisDay > daysback or
showontodayonly and GetDay() != GetLastDay()
then Double.NaN
else vahigh;
plot vahigh1 = vh1;
def vl1 = if extend_plot and IsNaN(close)
then vl1[1]
else if thisDay > daysback or
showontodayonly and GetDay() != GetLastDay()
then Double.NaN
else valow;
plot valow1 = vl1;
poc1.SetDefaultColor(Color.CYAN);
vahigh1.SetDefaultColor(Color.YELLOW);
valow1.SetDefaultColor(Color.YELLOW);
#Bubble
input showbubble = yes;
input bubblemover = 3;
input showValuesinBubble = yes;
def b = bubblemover;
def bm = bubblemover;
def bm1 = bm + 1;
AddChartBubble(showbubble and IsNaN(close[bm]) and !IsNaN(close[bm1]), poc1[bm1],
if showValuesinBubble then "POC $" + poc1[bm1] else "POC", Color.PINK, yes);
AddChartBubble(showbubble and IsNaN(close[bm]) and !IsNaN(close[bm1]), vahigh1[bm1],
if showValuesinBubble then "VAH $" + vahigh1[bm1] else "VAH", Color.GREEN, yes);
AddChartBubble(showbubble and IsNaN(close[bm]) and !IsNaN(close[bm1]), valow1[bm1],
if showValuesinBubble then "VAL $" + valow1[bm1] else "VAL", Color.RED, yes);
#