• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

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);
 

RickAns

Active member
VIP
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

Top