def HAclose = ohlc4;
def HAopen = CompoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh = Max( high, Max( HAopen, HAclose ) );
def HAlow = Min( low, Min( HAopen, HAclose ) );
def H = if Barnumber() == 1
then HAhigh
else if HAhigh > H[1]
then HAhigh
else if HAhigh < H[1]
then HAhigh
else H[1];
plot HH = if H[1] < H and H > H[-1]
then H
else Double.NaN;
HH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
def H0 = if !IsNaN(HH) != !IsNaN(HH[1])
then HAhigh
else h0[1];
def H1 = if h0[1] != h0
then h0[1]
else h1[1];
AddChartBubble(
isnan(HH[1]) and HH,
HAhigh,
if HH > h1[1] then "HH" else "LH",
if HH > h1[1] then Color.LIGHT_GREEN else Color.LIGHT_RED);
def L = if Barnumber() == 1
then HAlow
else if HAlow < L[1]
then HAlow
else if HAlow > L[1]
then HAlow
else L[1];
plot LL = if L[1] > L and L < L[-1]
then L
else Double.NaN;
LL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
def L0 = if !IsNaN(LL) != !IsNaN(LL[1])
then HAlow
else L0[1];
def L1 = if L0[1] != L0
then L0[1]
else L1[1];
AddChartBubble(
isnan(LL[1]) and LL,
HAlow,
if LL > L1[1] then "HL" else "LL",
if LL > L1[1] then Color.LIGHT_GREEN else Color.LIGHT_RED, no);