input pricecolor = yes;
def yyyymmdd = GetYYYYMMDD();
def period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
;
def cond = 0 < period - period[1];
profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, numberOfProfiles = 1, "value area percent" = 0.0, pricePerRow = PricePerRow.TICKSIZE);
plot b = vol.GetPointOfControl();
input showlabel = yes;
AddLabel(showlabel, "Close: " + AsText(close) + " POC: " + AsText(b) + " %Var: " + AsPercent((close - b) / b), if close > b then Color.GREEN else if close < b then Color.RED else Color.WHITE);
input showcloud = yes;
def bn = BarNumber();
def crossbn = if close crosses b then bn else Double.NaN;
def touch = Between(b, low, high);
AddCloud(if showcloud and !touch and bn >= HighestAll(crossbn) then close else Double.NaN, b, Color.GREEN, Color.RED);
input showvertical = yes;
AddVerticalLine(showvertical and close crosses b, "", if close crosses above b then Color.GREEN else Color.RED);
#Buying/Selling Pressure
input length = 10;
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);
def Delt = Buying - Selling;
input showdelta = yes;
input bubbleoffset = 1;
plot Delta = Delt;
AddChartBubble(showdelta and !IsNaN(close), low - bubbleoffset * TickSize(),
if absvalue(Delta) > 1000
then Round(Delta / 1000, 0) + "k"
else delta + "",
delta.TakeValueColor(), no);
Delta.AssignValueColor(if Delta > 0 then Color.GREEN else Color.RED);
Delta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Delta.Hide();
def zero = 0;
#zero.setDefaultColor(Color.BLUE);
def CumulativeVolumeDelta = Sum(Delta, length);
AssignPriceColor(if !pricecolor then Color.CURRENT else
if CumulativeVolumeDelta > 0
then Color.GREEN
else Color.RED);
#CumulativeVolumeDelta.AssignValueColor(if CumulativeVolumeDelta > 0 then Color.GREEN else Color.RED);
#CumulativeVolumeDelta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);