Please does anyone have indicator that will show gaps on Daily chart or will shows gaps in both daily and interday chart?
Thanks
Please does anyone have indicator that will show gaps on Daily chart or will shows gaps in both daily and interday chart?
Thanks
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Looking to get the bubble to identify if the gap has been crossed. i think the bubble can update with the correct code to represent zero when gap becomes closed; then cancel bubble from showing, struggling to get this. i think this is your code @halcyonguy great work and thanks. Any skills are appreciated @MerryDay
##################################[/INDENT]
##################################
# bargaps_06
def hi = high;
def lo = low;
def opn = open;
def cls = close;
def na = Double.NaN;
def bn = BarNumber();
# pick price level - prev bar
input prev_bar_price = { high_low , default close };
def prevhi;
def prevlo;
switch (prev_bar_price) {
case high_low:
prevhi = hi[1];
prevlo = lo[1];
case close:
prevhi = cls[1];
prevlo = cls[1];
}
# ----------------------
# current bar
def currhi = hi;
def currlo = lo;
#----------------------------------
input reduce_gaps = yes;
input min_gap_percent = 1.0;
#def per_digits = 1;
AddLabel(1, "find gaps that are > " + min_gap_percent + " % of price", Color.YELLOW);
input show_gap_clouds = yes;
input show_gap_stats_bubbles = no;
#----------------------------------
# if a gap, set gap high and low, and gap dir
def gaphi;
def gaplo;
def dir;
if bn == 1 then {
gaphi = hl2;
gaplo = hl2;
dir = 0;
} else if prevhi < currlo then {
# gap up , high to low
gaphi = currlo;
gaplo = prevhi;
dir = if gaphi > gaplo then 1 else 0;
} else if prevlo > currhi then {
# gap down , low to high
gaphi = prevlo;
gaplo = currhi;
dir = if gaphi > gaplo then -1 else 0;
} else {
gaphi = hl2;
gaplo = hl2;
dir = 0;
}
# ---------------------------------
# determine the gap , + or - number
def gap = if dir > 0 then round(gaphi - gaplo, 2)
else if dir < 0 then round(gaplo - gaphi, 2)
else 0;
# check if gap is > min %
def gap_per = if gap == 0 then 0 else Round((gap / gaplo) * 100, 1);
def gap_en = (absvalue(gap_per) > min_gap_percent);
# ----------------------------------------------
# counter of gaps
def gapqty = 4;
def cnt = if bn == 1 then 0
else if gap_en then cnt[1] + 1
else cnt[1];
# sequence counter, thru the qty
# 1,2,3,0,1,2,3,0...
def seq = cnt % gapqty;
def is_first_gap = cnt > 0 and seq == 1;
def is_last_gap = seq == 0;
# colors for gaps
def col_gap = if dir > 0 then Color.GREEN else Color.RED;
def col_neutral = Color.LIGHT_GRAY;
# plot cloud for gap, between gap hi and gap lo
AddCloud(gaphi, gaplo, col_gap, col_gap, yes) if (gap_en and show_gap_clouds and is_first_gap);
# plot bubble for gap, at price of gap hi
AddChartBubble(is_last_gap and show_gap_stats_bubbles, gaphi, "Gap\n" + gap + "\n" + gap_per + "%", col_gap, yes);
[INDENT=3]#
I am not a coder just trial and error. This is how far I got it's pretty hard.Looking to get the bubble to identify if the gap has been crossed. i think the bubble can update with the correct code to represent zero when gap becomes closed; then cancel bubble from showing, struggling to get this. i think this is your code @halcyonguy great work and thanks. Any skills are appreciated @MerryDay
i included the bubble and changed to cents.
def gap_per = if gap == 0 then 0 else Round(gap); #------changed gap % to cents
AddChartBubble(show_gap_stats_bubbles and gap1_en, (if gap1dir > 0 then bubloy else bubhiy) , gap + "\n" , if gap1dir < 0 then color.red else if gap1dir > 0 then color.red else color.gray, (if gap1dir < 0 then yes else no) );
Code:##################################[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]##################################[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# bargaps_06[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def hi = high;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def lo = low;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def opn = open;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def cls = close;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def na = Double.NaN;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def bn = BarNumber();[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# pick price level - prev bar[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]input prev_bar_price = { high_low , default close };[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def prevhi;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def prevlo;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]switch (prev_bar_price) {[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]case high_low:[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]prevhi = hi[1];[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]prevlo = lo[1];[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]case close:[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]prevhi = cls[1];[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]prevlo = cls[1];[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]}[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# ----------------------[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# current bar[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def currhi = hi;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def currlo = lo;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]#----------------------------------[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]input reduce_gaps = yes;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]input min_gap_percent = 1.0;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]#def per_digits = 1;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]AddLabel(1, "find gaps that are > " + min_gap_percent + " % of price", Color.YELLOW);[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]input show_gap_clouds = yes;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]input show_gap_stats_bubbles = no;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]#----------------------------------[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# if a gap, set gap high and low, and gap dir[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def gaphi;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def gaplo;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def dir;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]if bn == 1 then {[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] gaphi = hl2;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] gaplo = hl2;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] dir = 0;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]} else if prevhi < currlo then {[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# gap up , high to low[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] gaphi = currlo;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] gaplo = prevhi;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] dir = if gaphi > gaplo then 1 else 0;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]} else if prevlo > currhi then {[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# gap down , low to high[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] gaphi = prevlo;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] gaplo = currhi;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] dir = if gaphi > gaplo then -1 else 0;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]} else {[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] gaphi = hl2;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] gaplo = hl2;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] dir = 0;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]}[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# ---------------------------------[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# determine the gap , + or - number[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def gap = if dir > 0 then round(gaphi - gaplo, 2)[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]else if dir < 0 then round(gaplo - gaphi, 2)[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]else 0;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# check if gap is > min %[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def gap_per = if gap == 0 then 0 else Round((gap / gaplo) * 100, 1);[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def gap_en = (absvalue(gap_per) > min_gap_percent);[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# ----------------------------------------------[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# counter of gaps[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def gapqty = 4;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def cnt = if bn == 1 then 0[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] else if gap_en then cnt[1] + 1[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3] else cnt[1];[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# sequence counter, thru the qty[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# 1,2,3,0,1,2,3,0...[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def seq = cnt % gapqty;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def is_first_gap = cnt > 0 and seq == 1;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def is_last_gap = seq == 0;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# colors for gaps[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def col_gap = if dir > 0 then Color.GREEN else Color.RED;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]def col_neutral = Color.LIGHT_GRAY;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# plot cloud for gap, between gap hi and gap lo[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]AddCloud(gaphi, gaplo, col_gap, col_gap, yes) if (gap_en and show_gap_clouds and is_first_gap);[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]# plot bubble for gap, at price of gap hi[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]AddChartBubble(is_last_gap and show_gap_stats_bubbles, gaphi, "Gap\n" + gap + "\n" + gap_per + "%", col_gap, yes);[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3][INDENT=3]#
input Showremaning = yes;
# gap1
def percent_remaining_gap1 = if gap1_en then
if gap1dir == 1 then
Round(((top1b - lo) / (top1b - bot1b)) * 100, 1)
else if gap1dir == -1 then
Round(((hi - bot1b) / (top1b - bot1b)) * 100, 1)
else 0
else 0;
# display the bubble with information about gap1 and percent remaining
AddChartBubble(Showremaning and gap1_en,
(if gap1dir > 0 then bubloy else bubhiy), gap + "\n" +
percent_remaining_gap1 + "% GR 1",
if gap1dir < 0 then Color.RED else if gap1dir > 0 then Color.GREEN else Color.GRAY,
(if gap1dir < 0 then yes else no));
# gap2
def percent_remaining_gap2 = if gap2_en then
if gap2dir == 1 then
Round(((top2b - lo) / (top2b - bot2b)) * 100, 1)
else if gap2dir == -1 then
Round(((hi - bot2b) / (top2b - bot2b)) * 100, 1)
else 0
else 0;
# display the bubble with information about gap2 and percent remaining
AddChartBubble(Showremaning and gap2_en,
(if gap2dir > 0 then bubloy else bubhiy), gap + "\n" +
percent_remaining_gap2 + "% GR 2",
if gap2dir < 0 then Color.RED else if gap2dir > 0 then Color.GREEN else Color.GRAY,
(if gap2dir < 0 then yes else no));
# gap3
def percent_remaining_gap3 = if gap3_en then
if gap3dir == 1 then
Round(((top3b - lo) / (top3b - bot3b)) * 100, 1)
else if gap3dir == -1 then
Round(((hi - bot3b) / (top3b - bot3b)) * 100, 1)
else 0
else 0;
# display the bubble with information about gap3 and percent remaining
AddChartBubble(Showremaning and gap3_en,
(if gap3dir > 0 then bubloy else bubhiy), gap + "\n" +
percent_remaining_gap3 + "% GR 3",
if gap3dir < 0 then Color.RED else if gap3dir > 0 then Color.GREEN else Color.GRAY,
(if gap3dir < 0 then yes else no));
# gap4
def percent_remaining_gap4 = if gap4_en then
if gap4dir == 1 then
Round(((top4b - lo) / (top4b - bot4b)) * 100, 1)
else if gap4dir == -1 then
Round(((hi - bot4b) / (top4b - bot4b)) * 100, 1)
else 0
else 0;
# display the bubble with information about gap4 and percent remaining
AddChartBubble(Showremaning and gap4_en,
(if gap4dir > 0 then bubloy else bubhiy), gap + "\n" +
percent_remaining_gap4 + "% GR 4",
if gap4dir < 0 then Color.RED else if gap4dir > 0 then Color.GREEN else Color.GRAY,
(if gap4dir < 0 then yes else no));
Thanks for the updated code. It still does not seem to extend all unfilled gaps to the current candle. Anyone have any thoughts on how to accomplish this? I have added 8 gaps at this point. I am showing only six gaps on my chart but the two previous gaps are not extending all of the way to the current candle. Would also be ideal if there was an input with the option to stop showing all filled gaps. Let me know if anyone can help.I am not a coder just trial and error. This is how far I got it's pretty hard.
The bubble names set are %% GR (gap reduction)
Still trying...
View attachment 20484
@halcyonguy nice job on the script. Do you have a version with this gap
reduction bubble
View attachment 20491?
Thank you.
Code:input Showremaning = yes; # gap1 def percent_remaining_gap1 = if gap1_en then if gap1dir == 1 then Round(((top1b - lo) / (top1b - bot1b)) * 100, 1) else if gap1dir == -1 then Round(((hi - bot1b) / (top1b - bot1b)) * 100, 1) else 0 else 0; # display the bubble with information about gap1 and percent remaining AddChartBubble(Showremaning and gap1_en, (if gap1dir > 0 then bubloy else bubhiy), gap + "\n" + percent_remaining_gap1 + "% GR 1", if gap1dir < 0 then Color.RED else if gap1dir > 0 then Color.GREEN else Color.GRAY, (if gap1dir < 0 then yes else no)); # gap2 def percent_remaining_gap2 = if gap2_en then if gap2dir == 1 then Round(((top2b - lo) / (top2b - bot2b)) * 100, 1) else if gap2dir == -1 then Round(((hi - bot2b) / (top2b - bot2b)) * 100, 1) else 0 else 0; # display the bubble with information about gap2 and percent remaining AddChartBubble(Showremaning and gap2_en, (if gap2dir > 0 then bubloy else bubhiy), gap + "\n" + percent_remaining_gap2 + "% GR 2", if gap2dir < 0 then Color.RED else if gap2dir > 0 then Color.GREEN else Color.GRAY, (if gap2dir < 0 then yes else no)); # gap3 def percent_remaining_gap3 = if gap3_en then if gap3dir == 1 then Round(((top3b - lo) / (top3b - bot3b)) * 100, 1) else if gap3dir == -1 then Round(((hi - bot3b) / (top3b - bot3b)) * 100, 1) else 0 else 0; # display the bubble with information about gap3 and percent remaining AddChartBubble(Showremaning and gap3_en, (if gap3dir > 0 then bubloy else bubhiy), gap + "\n" + percent_remaining_gap3 + "% GR 3", if gap3dir < 0 then Color.RED else if gap3dir > 0 then Color.GREEN else Color.GRAY, (if gap3dir < 0 then yes else no)); # gap4 def percent_remaining_gap4 = if gap4_en then if gap4dir == 1 then Round(((top4b - lo) / (top4b - bot4b)) * 100, 1) else if gap4dir == -1 then Round(((hi - bot4b) / (top4b - bot4b)) * 100, 1) else 0 else 0; # display the bubble with information about gap4 and percent remaining AddChartBubble(Showremaning and gap4_en, (if gap4dir > 0 then bubloy else bubhiy), gap + "\n" + percent_remaining_gap4 + "% GR 4", if gap4dir < 0 then Color.RED else if gap4dir > 0 then Color.GREEN else Color.GRAY, (if gap4dir < 0 then yes else no));
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
M | Daily Volume Incorrect? | Questions | 0 | |
I | MTF Average Daily Close Line | Questions | 2 | |
R | Daily Volume Profile | Questions | 1 | |
B | Daily 20sma Watchlist | Questions | 1 | |
T | 20% Daily Move Scan | Questions | 0 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.