ChartBubble issue

hooptownla

New member
I have this code below and what I really want to accomplish is for the chart bubble is disappear after the next candle since my chart gets too messy with the repeating chartbubble for occurrence of triggers.
In this example of my chart, it shows "ShootingStar" multiple times but what I really want to do is for the "ShootingStar" bubble to disappear after the next candle or if the BearishEngulfing signal is triggered. Help

def ShootingStar = close > open[1] and open < close[1] and close[1] < sma21;

def BearishEngulfing = close < open[1] and open > close[1] and sma21> close[1];


# Display labels on the chart with timestamp
AddLabel(BullishEngulfing, "BULLISH ENGULFING CANDLE is true at " + hour + ":" + (if minutes < 10 then "0" else "") + minutes, if BullishEngulfing then Color.GREEN else Color.BLACK);
AddLabel(BearishEngulfing, "BEARISH ENGULFING CANDLE is true at " + hour + ":" + (if minutes < 10 then "0" else "") + minutes, if BearishEngulfing then Color.RED else Color.BLACK);

# Display bubble chart on the candle where the pattern occurred
AddChartBubble(ShootingStar, low, "ShootingStar", Color.GREEN, yes);
AddChartBubble(BearishEngulfing, high, "Bearish Engulfing", Color.RED, yes);
#
#added AddChartBubble functions to display a message on the candle where the Bullish or Bearish Engulfing pattern occurred.

# Hide the bubble on the next candle
AddChartBubble(ShootingStar[1], low[1], "", Color.UPTICK, yes, no);
AddChartBubble(BearishEngulfing[1], high[1], "", Color.DOWNTICK, yes, no);

1700501869963.png
 
Wanted to add label once condition is triggered but disappears on the next bar since the condition is no longer

AddLabel(ShowBullishEngulfing, "BULLISH ENGULFING CANDLE is true: " + BullishEngulfing, If(BullishEngulfing = TRUE then Color.GREENWedge else if (BullishEngulfing = FALSE then BLANK );

Want the label "BULLISH ENGULFING CANDLE is true: " be displayed on the chart once it occurs but becomes blank or turned off after the following bar. Somehow BLANK is not valid.
Please help
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Wanted to add label once condition is triggered but disappears on the next bar since the condition is no longer

AddLabel(ShowBullishEngulfing, "BULLISH ENGULFING CANDLE is true: " + BullishEngulfing, If(BullishEngulfing = TRUE then Color.GREENWedge else if (BullishEngulfing = FALSE then BLANK );

Want the label "BULLISH ENGULFING CANDLE is true: " be displayed on the chart once it occurs but becomes blank or turned off after the following bar. Somehow BLANK is not valid.
Please help

the color could be anything, the label will be off, it wont be seen
AddLabel(
ShowBullishEngulfing,
"BULLISH ENGULFING CANDLE is true: " + BullishEngulfing,
If BullishEngulfing then Color.GREEN else color.gray);

this group is for working studies, not questions


in the future, post complete code. it is near impossible to fix partial code. or someone has to recreate the missing code to test it.
 
Last edited by a moderator:
I have this code below and what I really want to accomplish is for the chart bubble is disappear after the next candle since my chart gets too messy with the repeating chartbubble for occurrence of triggers.
In this example of my chart, it shows "ShootingStar" multiple times but what I really want to do is for the "ShootingStar" bubble to disappear after the next candle or if the BearishEngulfing signal is triggered. Help

def ShootingStar = close > open[1] and open < close[1] and close[1] < sma21;

def BearishEngulfing = close < open[1] and open > close[1] and sma21> close[1];


# Display labels on the chart with timestamp
AddLabel(BullishEngulfing, "BULLISH ENGULFING CANDLE is true at " + hour + ":" + (if minutes < 10 then "0" else "") + minutes, if BullishEngulfing then Color.GREEN else Color.BLACK);
AddLabel(BearishEngulfing, "BEARISH ENGULFING CANDLE is true at " + hour + ":" + (if minutes < 10 then "0" else "") + minutes, if BearishEngulfing then Color.RED else Color.BLACK);

# Display bubble chart on the candle where the pattern occurred
AddChartBubble(ShootingStar, low, "ShootingStar", Color.GREEN, yes);
AddChartBubble(BearishEngulfing, high, "Bearish Engulfing", Color.RED, yes);
#
#added AddChartBubble functions to display a message on the candle where the Bullish or Bearish Engulfing pattern occurred.

# Hide the bubble on the next candle
AddChartBubble(ShootingStar[1], low[1], "", Color.UPTICK, yes, no);
AddChartBubble(BearishEngulfing[1], high[1], "", Color.DOWNTICK, yes, no);


an alternative would be to draw a different shape.
i used dots to indicate an engulfing pattern, instead of a bubble. that way they don't cover up anything.

i added the ability to choose wicks or body, to determine the patterns.

i changed the labels, so they always a ppear, and show the time of most recent engulfings. (may be a previous day)

i changed the formulas for engulfing. the originals don't include looking at an average.
i disabled the shooting star

i left a lot of commented code in, so you could change it around.

some patterns
https://trendspider.com/learning-center/engulfing-candlestick-patterns-a-traders-guide/
https://commodity.com/technical-analysis/shooting-star/
https://commodity.com/technical-analysis/hanging-man/
https://commodity.com/technical-analysis/candlestick-basics/


Code:
#hide_bubbles_engulf

#https://usethinkscript.com/threads/chartbubble-issue.17269/
#ChartBubble issue
#hooptownla  Nov 20, 2023

#I have this code below and what I really want to accomplish is for the chart bubble is disappear after the next candle since my chart gets too messy with the repeating chartbubble for occurrence of triggers.
#In this example of my chart, it shows "ShootingStar" multiple times but what I really want to do is for the "ShootingStar" bubble to disappear after the next candle or if the BearishEngulfing signal is triggered. Help


def na = Double.NaN;
def bn = BarNumber();
def big = 99999;

def up = close > open;
def dwn = close < open;

def clsx = if !isnan(close) then close else clsx[1];

#addchartbubble(1,179, clsx, color.yellow);

#-------------------------------
input timezone = {default "ET", "CT", "MT", "PT"};

def zoneoffset =
      (if timezone == timezone."ET" then 0
  else if timezone == timezone."CT" then -1
  else if timezone == timezone."MT" then -2
  else -3);

def start = 0;
def min1 = SecondsFromTime(start) / 60;
def hr1 = Floor(min1 / 60);
def hr2 = if (hr1 + zoneoffset) > 12 then (hr1 + zoneoffset) - 12 else (hr1 + zoneoffset);
def min2 = (min1 - (hr1*60) );

#AddLabel(yes, hr2 + " : " + min2, Color.MAGENTA);

#----------------------------

# choose wicks or body for patterns
input candle_levels = {default "wick" , "body" };
def highx;
def lowx;
def typex;
switch (candle_levels) {
case "wick":
  highx = high;
  lowx = low;
  typex = 1;
case "body":
  highx = max(open, close);
  lowx = min(open, close);
  typex = 2;
}

addlabel(yes, "patterns: " + (if typex == 1 then "Wicks" else "Body"), color.yellow);
addlabel(1, "  ", color.black);

#----------------------------


input avg_type = AverageType.SIMPLE;
#input avg_type = AverageType.exponential;
input avg_data = close;
input avg_len = 21;
def avg = MovingAverage( avg_type , avg_data , avg_len );
plot zavg = avg;
#
def sma21 = avg;
#-----------------------

# wrong
#def ShootingStar = close > open[1] and open < close[1] and close[1] < sma21;
#def BearishEngulfing = close < open[1] and open > close[1] and sma21 > close[1];
#def BullishEngulfing = close > open[1] and open < close[1] and sma21 < close[1];


#def ShootingStar = close > open[1] and open < close[1] and close[1] < sma21;
def ShootingStar = 0;



# engulfing,   a small candle is followed by a larger candle that fully ‘engulfs’ the prior one.
def Bearish_Engulfing = dwn and highx >= highx[1] and lowx <= lowx[1];
def Bullish_Engulfing = up and highx >= highx[1] and lowx <= lowx[1];

input show_engulfing_dots = yes;
def dot_vert = 0.0005;
plot zenup = if show_engulfing_dots and Bearish_Engulfing then low*(1-dot_vert) else na;
zenup.SetPaintingStrategy(PaintingStrategy.points);
zenup.SetDefaultColor(Color.red);
zenup.setlineweight(4);
zenup.hidebubble();

plot zendwn = if show_engulfing_dots and Bullish_Engulfing then high*(1+dot_vert) else na;
zendwn.SetPaintingStrategy(PaintingStrategy.points);
zendwn.SetDefaultColor(Color.green);
zendwn.setlineweight(4);
zendwn.hidebubble();


def bearenhr = if bn == 1 then 0 else if Bearish_Engulfing then hr2 else bearenhr[1];
def bearenmin = if bn == 1 then 0 else if Bearish_Engulfing then min2 else bearenmin[1];
def bullenhr = if bn == 1 then 0 else if Bullish_Engulfing then hr2 else bullenhr[1];
def bullenmin = if bn == 1 then 0 else if Bullish_Engulfing then min2 else bullenmin[1];


# Display labels on the chart with timestamp
# only when the signal happens
#AddLabel(BullishEngulfing, "BULLISH ENGULFING CANDLE is true at " + hour + ":" + (if minutes < 10 then "0" else "") + minutes, if BullishEngulfing then Color.GREEN else Color.BLACK);
#AddLabel(BearishEngulfing, "BEARISH ENGULFING CANDLE is true at " + hour + ":" + (if minutes < 10 then "0" else "") + minutes, if BearishEngulfing then Color.RED else Color.BLACK);


# show last signal
AddLabel(1, "BULLISH ENGULFING at " + bullenhr + ":" + (if bullenmin < 10 then "0" else "") + bullenmin, if Bullish_Engulfing then Color.GREEN else Color.gray);

AddLabel(1, "BEARISH ENGULFING at " + bearenhr + ":" + (if bearenmin < 10 then "0" else "") + bearenmin, if Bearish_Engulfing then Color.RED else Color.gray);


input show_engulfing_bubbles = no;
def bub_vert = dot_vert + 0.001;
# Display bubble chart on the candle where the pattern occurred
AddChartBubble(show_engulfing_bubbles and ShootingStar, low*(1-bub_vert), "Shooting\nStar", Color.GREEN, no);
AddChartBubble(show_engulfing_bubbles and Bearish_Engulfing, high*(1+bub_vert), "Bearish\nEngulfing", Color.RED, yes);


#added AddChartBubble functions to display a message on the candle where the Bullish or Bearish Engulfing pattern occurred.

# Hide the bubble on the next candle
#AddChartBubble(ShootingStar[1], low[1], "", Color.UPTICK, yes, no);
#AddChartBubble(BearishEngulfing[1], high[1], "", Color.DOWNTICK, yes, no);

#addlabel(1, "  ", color.black);

input show_legend = no;
def w = 5;
def w2 = (!isnan(close[w+1]) and isnan(close[w]));

addchartbubble(show_legend and w2, clsx,
"Dot - Engulfing\n" + 
"small / big"
, color.yellow, yes);
#

vLTf0bQ.jpg
 
an alternative would be to draw a different shape.
i used dots to indicate an engulfing pattern, instead of a bubble. that way they don't cover up anything.

i added the ability to choose wicks or body, to determine the patterns.

i changed the labels, so they always a ppear, and show the time of most recent engulfings. (may be a previous day)

i changed the formulas for engulfing. the originals don't include looking at an average.
i disabled the shooting star

i left a lot of commented code in, so you could change it around.

some patterns
https://trendspider.com/learning-center/engulfing-candlestick-patterns-a-traders-guide/
https://commodity.com/technical-analysis/shooting-star/
https://commodity.com/technical-analysis/hanging-man/
https://commodity.com/technical-analysis/candlestick-basics/


Code:
#hide_bubbles_engulf

#https://usethinkscript.com/threads/chartbubble-issue.17269/
#ChartBubble issue
#hooptownla  Nov 20, 2023

#I have this code below and what I really want to accomplish is for the chart bubble is disappear after the next candle since my chart gets too messy with the repeating chartbubble for occurrence of triggers.
#In this example of my chart, it shows "ShootingStar" multiple times but what I really want to do is for the "ShootingStar" bubble to disappear after the next candle or if the BearishEngulfing signal is triggered. Help


def na = Double.NaN;
def bn = BarNumber();
def big = 99999;

def up = close > open;
def dwn = close < open;

def clsx = if !isnan(close) then close else clsx[1];

#addchartbubble(1,179, clsx, color.yellow);

#-------------------------------
input timezone = {default "ET", "CT", "MT", "PT"};

def zoneoffset =
      (if timezone == timezone."ET" then 0
  else if timezone == timezone."CT" then -1
  else if timezone == timezone."MT" then -2
  else -3);

def start = 0;
def min1 = SecondsFromTime(start) / 60;
def hr1 = Floor(min1 / 60);
def hr2 = if (hr1 + zoneoffset) > 12 then (hr1 + zoneoffset) - 12 else (hr1 + zoneoffset);
def min2 = (min1 - (hr1*60) );

#AddLabel(yes, hr2 + " : " + min2, Color.MAGENTA);

#----------------------------

# choose wicks or body for patterns
input candle_levels = {default "wick" , "body" };
def highx;
def lowx;
def typex;
switch (candle_levels) {
case "wick":
  highx = high;
  lowx = low;
  typex = 1;
case "body":
  highx = max(open, close);
  lowx = min(open, close);
  typex = 2;
}

addlabel(yes, "patterns: " + (if typex == 1 then "Wicks" else "Body"), color.yellow);
addlabel(1, "  ", color.black);

#----------------------------


input avg_type = AverageType.SIMPLE;
#input avg_type = AverageType.exponential;
input avg_data = close;
input avg_len = 21;
def avg = MovingAverage( avg_type , avg_data , avg_len );
plot zavg = avg;
#
def sma21 = avg;
#-----------------------

# wrong
#def ShootingStar = close > open[1] and open < close[1] and close[1] < sma21;
#def BearishEngulfing = close < open[1] and open > close[1] and sma21 > close[1];
#def BullishEngulfing = close > open[1] and open < close[1] and sma21 < close[1];


#def ShootingStar = close > open[1] and open < close[1] and close[1] < sma21;
def ShootingStar = 0;



# engulfing,   a small candle is followed by a larger candle that fully ‘engulfs’ the prior one.
def Bearish_Engulfing = dwn and highx >= highx[1] and lowx <= lowx[1];
def Bullish_Engulfing = up and highx >= highx[1] and lowx <= lowx[1];

input show_engulfing_dots = yes;
def dot_vert = 0.0005;
plot zenup = if show_engulfing_dots and Bearish_Engulfing then low*(1-dot_vert) else na;
zenup.SetPaintingStrategy(PaintingStrategy.points);
zenup.SetDefaultColor(Color.red);
zenup.setlineweight(4);
zenup.hidebubble();

plot zendwn = if show_engulfing_dots and Bullish_Engulfing then high*(1+dot_vert) else na;
zendwn.SetPaintingStrategy(PaintingStrategy.points);
zendwn.SetDefaultColor(Color.green);
zendwn.setlineweight(4);
zendwn.hidebubble();


def bearenhr = if bn == 1 then 0 else if Bearish_Engulfing then hr2 else bearenhr[1];
def bearenmin = if bn == 1 then 0 else if Bearish_Engulfing then min2 else bearenmin[1];
def bullenhr = if bn == 1 then 0 else if Bullish_Engulfing then hr2 else bullenhr[1];
def bullenmin = if bn == 1 then 0 else if Bullish_Engulfing then min2 else bullenmin[1];


# Display labels on the chart with timestamp
# only when the signal happens
#AddLabel(BullishEngulfing, "BULLISH ENGULFING CANDLE is true at " + hour + ":" + (if minutes < 10 then "0" else "") + minutes, if BullishEngulfing then Color.GREEN else Color.BLACK);
#AddLabel(BearishEngulfing, "BEARISH ENGULFING CANDLE is true at " + hour + ":" + (if minutes < 10 then "0" else "") + minutes, if BearishEngulfing then Color.RED else Color.BLACK);


# show last signal
AddLabel(1, "BULLISH ENGULFING at " + bullenhr + ":" + (if bullenmin < 10 then "0" else "") + bullenmin, if Bullish_Engulfing then Color.GREEN else Color.gray);

AddLabel(1, "BEARISH ENGULFING at " + bearenhr + ":" + (if bearenmin < 10 then "0" else "") + bearenmin, if Bearish_Engulfing then Color.RED else Color.gray);


input show_engulfing_bubbles = no;
def bub_vert = dot_vert + 0.001;
# Display bubble chart on the candle where the pattern occurred
AddChartBubble(show_engulfing_bubbles and ShootingStar, low*(1-bub_vert), "Shooting\nStar", Color.GREEN, no);
AddChartBubble(show_engulfing_bubbles and Bearish_Engulfing, high*(1+bub_vert), "Bearish\nEngulfing", Color.RED, yes);


#added AddChartBubble functions to display a message on the candle where the Bullish or Bearish Engulfing pattern occurred.

# Hide the bubble on the next candle
#AddChartBubble(ShootingStar[1], low[1], "", Color.UPTICK, yes, no);
#AddChartBubble(BearishEngulfing[1], high[1], "", Color.DOWNTICK, yes, no);

#addlabel(1, "  ", color.black);

input show_legend = no;
def w = 5;
def w2 = (!isnan(close[w+1]) and isnan(close[w]));

addchartbubble(show_legend and w2, clsx,
"Dot - Engulfing\n" +
"small / big"
, color.yellow, yes);
#

vLTf0bQ.jpg

Thank you. That idea is better since it will not clutter the chart.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
464 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top