Help With a Label Statement

Buckbull

Active member
I made this study for swing high and swing lows , I am a beginner i am looking to put a box in my watchlist column that turns red when a new SL is formed and Cyan when a new SH is formed , I know i need a label statement but Im at a loss of how to do it . Any help I would appreciate, Im surprised I was able to do this . My hat is off to the good script writers !! Amazing !

Code:
def swinghigh = if high > high[1] and high > high[2] and high > high[-1] and high > high[-2] then 1 else 0;
plot sh = if swinghigh then high else Double.NaN;
sh.SetStyle(Curve.POINTS);

def swinglow = if low < low[1] and low < low[2] and low < low[-1] and low < low[-2] then 1 else 0;
plot lw = if swinglow then low else Double.NaN;
lw.SetStyle(Curve.POINTS);
 

rad14733

Well-known member
VIP
Add this to the bottom of your code... You should be able to comment out the plots for use in a watchlist column...

Ruby:
addLabel(yes, " Trend ", if swinghigh then Color.RED else if swinglow then Color.GREEN else Color.GRAY);
 
R

RickAns

Guest
Looks like rad14733 has the right idea. Was going to suggest something like "AssignBackgroundColor(if swinghigh then Color.cyan else if swinglow then Color.red else Color.current);" but it does not seem to be working.
 

Buckbull

Active member
addLabel(yes, " Trend ", if swinghigh then Color.RED else if swinglow then Color.GREEN else Color.GRAY);
Im sorry i should have specified that i want to add it in my watchlist column (a custom column) so when one of my stocks that I like to trade puts in a swing high or swing low a box illuminates letting me know it did so red for swing high and green for swing low . Just the way my Daily 21 Moving Average box light up yellow when NVDA touched the 21 Daily MA today .

UzeX6jH.png
 

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.
Top