#Painting_candlesticks_on_gap_candles
input gappct = .01;
def o = open;
def h = high;
def l = low;
def c = close;
def op = open(period = AggregationPeriod.DAY);
def cl = close(period = AggregationPeriod.DAY);
#GapUp and GapDn defined
def gapup = if SecondsFromTime(0930) == 0 and (op - cl[1]) > cl[1] * gappct and close < open then 1 else 0;
def gapdn = if SecondsFromTime(0930) == 0 and AbsValue((op - cl[1])) > cl[1] * gappct
#(cl[1] - op) > op * gappct
and close > open then 1 else 0;
#Color Gapup or GapDn Candle the color of the chart background to hide it
DefineGlobalColor("Chart Background", Color.BLACK);
AssignPriceColor(if gapup or gapdn then GlobalColor("Chart Background") else Color.CURRENT);
#Highlight the border of the GapUp or GapDn candle Green/Red and hollow then body of these candles
input borderhighlight = yes;
input charttype = ChartType.CANDLE;
def cond = if borderhighlight and gapup then 1 else 0;
def o1 = if cond
then if o < c then c else o
else Double.NaN;
def c1 = if cond
then if o < c then o else c
else Double.NaN;
def h1 = if cond
then h
else Double.NaN;
def l1 = if cond
then l
else Double.NaN;
AddChart(growColor = Color.GREEN, fallColor = Color.BLUE, neutralColor = Color.BLUE, high = h1, low = l1, open = c1, close = o1, type = charttype);
def cond1 = if borderhighlight and gapdn then 1 else 0;
def o2 = if cond1
then if o < c then c else o
else Double.NaN;
def c2 = if cond1
then if o < c then o else c
else Double.NaN;
def h2 = if cond1
then h
else Double.NaN;
def l2 = if cond1
then l
else Double.NaN;
AddChart(growColor = Color.RED, fallColor = Color.RED, neutralColor = Color.RED, high = h2, low = l2, open = c2, close = o2, type = charttype);
#Test
input test = yes;
AddChartBubble(
test and SecondsFromTime(0930) == 0 and AbsValue(cl[1] - op) > 0,
high,
(if gapup then "GapUp: " else if gapdn then "GapDn: " else "Gap: ") + AbsValue(cl[1] - op) +
"\nPct " +
(AbsValue(cl[1] - op) / cl[1]) +
"\nBar:" +
(if c > o then "Grn" else "Red"),
if gapup then Color.GREEN else if gapdn then Color.RED else Color.GRAY);