RSI Format, Label, Watchlist, Scan For ThinkOrSwim

I would like to have a label (AddLabel) that tells me that the RSI trending higher or lower based on the close. Something like an if statement.
If the OHLC4 RSI percentage is higher than the previous RSI percentage on the the OHLC4 close then"Higher" the label will show Higher and the color I want to be green. Note: I can handle the color part, I just need help with this if statement.

How can I get that thought in ThinkScript?
 
@Branch Here is a simple label that compares two RSI values and displays whether the RSI is RISING or FALLING over n periods
I have color coded the label green, pink, and yellow

Code:
input n = 21;
def RSI_ = RSI(14, 70, 30, close, AverageType.WILDERS);
def RSIUP = RSI_ > RSI_[n];
def RSIDN = RSI_ < RSI_[n];
addlabel(1, "RSI : " + Round(RSI_,2) + (if RSIUP then " RISING [" + n + " BARS]"
                                        else if RSIDN then " FALLING [" + n + " BARS]"
                                        else " NEUTRAL"),
if RSIUP then Color.GREEN else if RSIDN then Color.PINK else Color.YELLOW);
 
@horserider Is it possible to make the label only paint the label green if the RSI value goes below 30 and only paint red if the value goes above 70? If not, can the label be colored grey if the value is currently between 30 and 70?

Thanks for a great script!
 
@horserider Is it possible to make the label only paint the label green if the RSI value goes below 30 and only paint red if the value goes above 70? If not, can the label be colored grey if the value is currently between 30 and 70?

Thanks for a great script!

@zeek - Here you go - as requested.

https://tos.mx/sdJ8vdI
Code:
input n = 21;
def RSI = RSI(14, 70, 30, close, AverageType.WILDERS);

def rsiUP = RSI < 30;
def rsiDN = RSI > 70;
def rsinet = !rsiUP and !rsiUP;

AddLabel(rsiUP, "  RSI < 30  ", Color.GREEN);
AddLabel(rsiDN, "  RSI > 70  ", Color.RED);
AddLabel(rsinet, " RSI between 30 & 70", Color.GRAY);
 
@zeek per your request I have modified @horserider RSI label code to display the label GREEN is RSI goes below 30 and paint it RED if RSI goes above 70. Otherwise RSI is not displayed

Code:
# SimpleMovingAvg RSI label by Horsrider 10/10/2019

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);

AddLabel(RSI < over_Sold or RSI > over_Bought, RSI, if RSI < over_Sold then Color.GREEN else Color.RED);
 
here is one label

Code:
#RSI label for upper study


input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input avg_type = AverageType.WILDERS;

def NetChgAvg = MovingAverage(avg_type, price - price[1], length);
def TotChgAvg = MovingAverage(avg_type, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = round(50 * (ChgRatio + 1),2);


AddLabel(1, (if avg_type == 0 then "RSI SMA" else if avg_type == 1 then "RSI EMA" else if avg_type == 2 then "RSI WMA" else if avg_type == 3 then "RSI Wldr" else "RSI Hull") + ": "+rsi+""+ if rsi==rsi[1] then " NC" else if  rsi>rsi[1] then " UP" else " DN", if between(rsi,30,70) then color.yellow else if rsi > 50 then if rsi<rsi[1] then color.dark_green else Color.GREEN else if rsi < 50 then if rsi>rsi[1] then color.dark_red else Color.RED else Color.DARK_GRAY);


#addlabel(yes,"RSI " +rsiavg, if rsiavg>70 then color.green else if rsiavg<30 then color.red else color.yellow);

######
 
Last edited by a moderator:
Does anyone have an RSI Label I can add to the chart ?

Thanks
Whipped one up real quick.. thank god for copy paste because I did not know the calculations for RSI off top haha
Code:
#RSILabel

input RSILength = 14;
input price = close;
input averageType = AverageType.WILDERS;
def NetChgAvg = MovingAverage(averageType, price - price[1], RSILength);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), RSILength);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);

AddLabel(yes, Concat("RSI=", RSI), Color.YELLOW);

Right as I post @J007RMC beat me to it haha
 
I wrote this code but i dont know if is correct or not sound like not give me good result

Code:
def ab =RSI()."RSI" is greater than RSI()."OverBought";
def bb = RSI()."RSI" is less than RSI()."OverSold";
plot value = if ab then 1 else if bb then -1 else 0;
AssignBackgroundColor(if value == 1 then color.YELLOW else if value == -1 then color.CYAN  else color.red);
value.AssignValueColor(if value == 1 then color.BLACK else if value == -1 then color.BLACK  else color.CURRENT);
 
Last edited by a moderator:
Hi, I have an RSI column on my watchlist and I would like to play a sound when it goes under 30.
I set up something in the thinkscript editor but it doesnt seem to work

def condition = if RSI < 30 then 1 else 0;
Alert(condition, ”oversold”, Alert.TICK, sound.ding);

Maybe I am doing something wrong?
Any help appreciated thank you!
 
I feel your pain, I having been looking for help on this forum to no avail. I use a separate computer with 2 monitors to show 40 tickers in a flexible grid with the RSI loaded on each. That is the best way I have found to not miss any action. I have never had any luck with TOS alerts.
 
You can setup a scanner for your condition, scan it within your own watchlist, and get alerted for new changes.
 
Yes you can, I have this alert set for RSI under 30 for symbols in my watch list. When you click the scan tab look two rows under it. You will see (Scan In) and next to it (Intersect With) Click those and find your watch list in the drop down menu. Set your scan and alert.
 
Do you know how to make the script for sound? I want to make one for RSI under 30 and one for Awesome Oscillator crossing under the zero line. I made one for the MACD but can't figure these two out.

Code:
#wizard input: crossingType
#wizard text: Inputs: fast length:
#wizard input: fastLength
#wizard text: slow length:
#wizard input: slowLength
#wizard text: macd length:
#wizard input: MACDLength
#wizard text: average type:
#wizard input: AverageType

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input crossingType = {default "Positive to Negative", "Negative to Positive"};

def Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;

plot signal = Crosses(Diff, 0, crossingType == crossingType."Negative to Positive");

signal.DefineColor("Negative to Positive", GetColor(2));
signal.DefineColor("Positive to Negative", GetColor(3));
signal.AssignValueColor(if crossingType == crossingType."Negative to Positive" then signal.Color("Negative to Positive") else signal.Color("Positive to Negative"));

signal.SetPaintingStrategy(if crossingType == crossingType."Negative to Positive"
    then PaintingStrategy.BOOLEAN_ARROW_UP
    else PaintingStrategy.BOOLEAN_ARROW_DOWN);

Alert(signal[0], "MACD Alert", Alert.BAR, Sound.Ring);

# chimes, ding, bell,
 
@Daughters Keeper You seem to already have the necessary method. :) So for the RSI, it would be something like
Code:
Alert(RSI crosses below Oversold, " Your Text Here ", Alert.Bar, Sound.Ring);
and for the Awesome Oscillator
Code:
Alert(AO crosses below Zero, " Your Text Here ", Alert.Bar, Sound.Ring);
 
Hello, Is there a way to scan a watchlist with the current price has just touched RSI 70% or 30% or within the last 5 bars? I am trying to find which stock on my watchlist is at oversold or overbought area within the last 5 bars. Thanks!!

Code:
# RSI Scan
# Nick Name NAG®
# 3.15.2016

# If you'd like to scan for stocks that have crossed the an input level (e.g. 30 level)
# on the RSI for the first time in 3 years.
#
# The scanner limitation is 750 daily bars. It doesn't go any further
# back than that. TOS limits historical scan data to 730 days for daily
# and up aggregation, so I'm not sure there's enough to do that accurately.
# This should get what's available within TOS limits.

rec rsi_cross = CompoundValue(1, if RSI() crosses above 30 then rsi_cross[1] + 1 else rsi_cross[1], 0);
plot scan = rsi_cross[1] == 0 and rsi_cross == 1;

# End Study
 
Last edited by a moderator:

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
397 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