Imitate %change watchlist column but with color

j0hnblake

New member
I'm unable to get this formula working quite the way I want. Surely there is no need for sacrifice and there is knowledge and betterment to be gained here.

I'm trying to create a watchlist column for the top% gainers on the day. With the column being sortable in ascending/descending as percent gained, displaying as lets say 63% with no decimal (not as 63.0%) the percent sign at the end (not in the beginning like %63) , and the text in color in green, yellow, or red.

Basically trying to imitate the default built in mark% change or change % column but with custom colors but I keep running into problems.

If I remove the percent from the end [AddLabel(yes, z + "%");] it works and the column is sortable but there is a decimal and .0 at the end displays as 63.0 in color.

If I add the percent at the end, the numbers displays like I want displays as 63% but I lose the color and ability to sort the column (it will just sort randomly not ascending/descending) if I put the percent sign before as %63 i can't add color.

Surely, there is a way,



Here is what I am working with

def AP = AggregationPeriod.DAY;
def y = close(period = AP)[1];
def x = Round(100*((close/y)-1),0);
plot z=x;
z.assignValueColor(if z >= 100 then Color.GREEN else if z >= 50 and z < 100 then Color.YELLOW else if z >= 10 and z < 50 then Color.ORANGE else Color.RED);
AddLabel(yes, z + "%");
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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