Show "Yes" or "No" in watchlist column with different background colors

Glefdar

Active member
Hi all,

I have labels showing in custom quotes using if/then/else, like this:

Code:
Addlabel(yes, if VARIABLENAME > 0 then "Yes" else "No");

What I want to do is something like this:

Code:
Addlabel(yes, if VARIABLENAME > 0 then "Yes" and Color.GREEN else "No" and Color.RED);

That doesn't work and I can't figure out any way to make it work. I know it's possible to set a color regardless of the if/then/else conditions (doing so when displaying a string value makes the text font have that color). I also know there are examples where the color changes when showing a value (like if the value returned by a formula is positive the number is green, if negative the number is red). But I can't find examples where the color coding is combined with specification of the string value. Does anyone know how to do it?
 
You're close...

Review AddLabel for a better understanding... There are three parameters for the function call and you are attempting to include the data for all three in just two... You have to use the same conditional logic for both the text and the color parameters...

Code:
AddLabel(boolean visible, Any text, CustomColor color);
 

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

@rad14733 Hi, thanks for your reply. Are you saying that this will work?

Code:
Addlabel(yes, if VARIABLENAME > 0 then "Yes", Color.GREEN);
Addlabel(yes, if VARIABLENAME < 0 then "No", Color.RED);

I think that won't work because I need an "else" condition in each Addlabel code bit. But I can't get the color labels to be included in the if / else conditions.
 
Or you can do it with the same conditional for both variables in one call...

Code:
Addlabel(yes, if VARIABLENAME > 0 then "Yes" else "No", if VARIABLENAME > 0 then Color.GREEN else Color.RED (y) );

I try to give enough help so folks can learn to Thinkscript rather than simply handing out code... You were VERY close...
 
That is really good to know, @rad14733 . Did not realize it was possible to do more than one 'if' in an AddLabel, etc line. My attempt would have been an 'else Double.NaN' in post #3 at then end of each line. Which may not have been the correct way to do it.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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