exit on AddChartBubble

aurelia0001

New member
Hi,
I am using a script which displays a number of labels on an indicator line using addchart, see pseudo code below.
If none of the conditions apply the label should not display.
As the conditions are quite extensive I rather not use all the conditions over again in the (first) time condition, but rather at the end of the color assignment if-then-else exit use something like a double.nan - but thinkscript does not allow this.
I can't seem to come up with a clever alternative, any suggestions how to deal with this?

JavaScript:
AddChartBubble(
  yes
, baseline
, " label text "
,      if cond1 then color1
  else if cond2 then color2
  else if etc. etc. (8 conditions in total)
  else  # do not show chartbubble / double.nan does not work
, yes);
 
Solution
Hi,
I am using a script which displays a number of labels on an indicator line using addchart, see pseudo code below.
If none of the conditions apply the label should not display.
As the conditions are quite extensive I rather not use all the conditions over again in the (first) time condition, but rather at the end of the color assignment if-then-else exit use something like a double.nan - but thinkscript does not allow this.
I can't seem to come up with a clever alternative, any suggestions how to deal with this?

JavaScript:
AddChartBubble(
  yes
, baseline
, " label text "
,      if cond1 then color1
  else if cond2 then color2
  else if etc. etc. (8 conditions in total)
  else  # do not show chartbubble / double.nan does not work
...
Hi,
I am using a script which displays a number of labels on an indicator line using addchart, see pseudo code below.
If none of the conditions apply the label should not display.
As the conditions are quite extensive I rather not use all the conditions over again in the (first) time condition, but rather at the end of the color assignment if-then-else exit use something like a double.nan - but thinkscript does not allow this.
I can't seem to come up with a clever alternative, any suggestions how to deal with this?

JavaScript:
AddChartBubble(
  yes
, baseline
, " label text "
,      if cond1 then color1
  else if cond2 then color2
  else if etc. etc. (8 conditions in total)
  else  # do not show chartbubble / double.nan does not work
, yes);

first thing,
just post the real code. no one is doing anything super secret, that hasn't been seen before.

learn and use the correct terms. your code is for a bubble, but you are calling it a label and addchart.

can you pull out some of the conditions and combine them to make its own formula, set to some variable? then reference that variable within the bubble.

or if things are getting that complicated, maybe separate out the formulas into 2+ bubbles?
try to group together conditions that have the same color.

combine all the valid conditions that would turn on the bubble, into a OR formula. then use that variable as the visible parameter.
def seen = ( cond1 or cond2 or cond3 or ....);
addchartbubble( seen, ... )

could pick a color the same as background color, ( black on black) then the bubble wouldn't be seen.
 
Solution
Thanks @halcyonguy for the suggestions. The real code is not super secret but a bit messy and lot's of lines/temp stuff which might add unnecessary confusion.

Setting the background color to black on black helps a little but that will sometimes overlap with other chartbubbles. I was hoping there was an easy way to exit the color assignment part of the AddChartBubble function but that seems not to be the case.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
347 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