RSI_Extreme Indicator for ThinkorSwim

rad14733

Well-known member
VIP
I have been using and improving the standard TOS RSI indicator for well over a year for my own personal use and have finally decided to release RSI_Extreme to the usethinkscript community... I use it on virtually every underlying chart while scalping options, in one variation or another...

As the name implies, it is RSI_Extreme due its overall versatility... So, what makes it "Extreme"...???

  • It can work just like the standard TOS RSI indicator if that is all you require...
  • You can drag the indicator into the upper chart panel for on-chart display (I use this feature a lot)...
  • You can enable/disable midlines which display at 40, 50, and 60...
  • You can enable/disable the standard 70/30 breakout signals (dots by default)...
  • You can enable/disable the standard RSI line...
  • You can enable/disable a horizontal RSI line that displays across the entire chart, similar to how a PriceLine works, complete with overbought/oversold markings (triangles by default)...
  • You can enable/disable a trend colored average line...
  • You can enable/disable vertical lines at Start and End trading times of your choice...
I urge the membership to not ask for additional customizations or for extensive support... I post this only for use as-is but you are free to customize it for your personal needs... The code works exceptionally well for my needs and I hope others will also find it useful...

Please Note:

As currently coded, the RSI Overbought and Oversold dots work differently than the breakouts in a standard RSI indicator... How they differ is that in a default indicator the "breakouts" fire when the RSI line crosses back over the overbought/oversold line after having previously crossed... In my indicator the breakouts fire and remain fired as long as RSI is beyond the breakout levels... I find it more important to know that entire event as it is happening rather than only after it has happened and is no longer happening...

Update History:
  • # v1.0 : 2020-09-01 : Original code with midlines
  • # v1.1 : 2020-09-15 : Modified settings for personal preference
  • # v1.2 : 2021-01-22 : Added option to plot vertical lines at Start and End times
  • # v1.3 : 2021-03-15 : Added option to plot horizontal rsiLine across chart at current RSI level
  • # v1.4 : 2021-03-29 : Added option to plot trending color average line
  • # v1.5 : 2021-03-29 : Added code to eliminate vertical lines for AggregationPeriods above Four_Hours
  • # v1.6 : 2021-03-29 : Added option to adjust RSI chart label decimal rounding

Ruby:
# RSI_Extreme
# Based on TOS standard RSI
# By: rad14733 on usethinkscript.com
# Can be used as either an upper or lower indicator. Drag into upper chart panel for on-chart display.
# v1.0 : 2020-09-01 : Original code with midlines
# v1.1 : 2020-09-15 : Modified settings for personal preference
# v1.2 : 2021-01-22 : Added option to plot vertical lines at Start and End times
# v1.3 : 2021-03-15 : Added option to plot horizontal rsiLine across chart at current RSI level
# v1.4 : 2021-03-29 : Added option to plot trending color average line
# v1.5 : 2021-03-29 : Added code to eliminate vertical lines for AggregationPeriods above Four_Hours
# v1.6 : 2021-03-29 : Added option to adjust RSI chart label decimal rounding

declare lower;

input length = 13;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = yes;
input showRSI = yes;
input showMidLines = yes;
input showRsiChartLabel = yes;
input rsiLabelDecimals = 4;
input showStartTimeLine = yes;
input showEndTimeLine = yes;
input startTime = 0930;
input endTime = 1600;
input showHorRsiLine = yes;
input showAvgRsi = yes;
input avgRsiLength = 3;
input avgRsiAverageType = 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);

plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if RSI <= OverSold then OverSold else Double.NaN;

plot DownSignal = if RSI >= OverBought then OverBought else Double.NaN;

plot forty = if showMidLines then 40 else Double.NaN;
forty.SetDefaultColor(Color.LIGHT_GRAY);
forty.SetPaintingStrategy(PaintingStrategy.DASHES);
forty.SetLineWeight(1);

plot fifty = if showMidLines then 50 else Double.NaN;
fifty.SetDefaultColor(Color.ORANGE);
fifty.SetPaintingStrategy(PaintingStrategy.DASHES);
fifty.SetLineWeight(1);

plot sixty = if showMidLines then 60 else Double.NaN;
sixty.SetDefaultColor(Color.LIGHT_GRAY);
sixty.SetPaintingStrategy(PaintingStrategy.DASHES);
sixty.SetLineWeight(1);

RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.color("OverBought") else if RSI < over_Sold then RSI.color("OverSold") else RSI.color("Normal"));
RSI.SetHiding(!showRSI);

OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));

UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.POINTS);
UpSignal.SetLineWeight(5);
UpSignal.SetHiding(!showBreakoutSignals);

DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.POINTS);
DownSignal.SetLineWeight(5);
DownSignal.SetHiding(!showBreakoutSignals);

#Place vertical lines at start and end times
def startTimeValue = SecondsFromTime(StartTime) == 0;
def endTimeValue = SecondsFromTime(endTime) == 0;
def aggOk = if GetAggregationPeriod() < AggregationPeriod.DAY then 1 else Double.NaN;
AddVerticalLine(aggOk and showStartTimeLine and startTimeValue,"Start",Color.GREEN,Curve.SHORT_DASH);
AddVerticalLine(aggOk and showEndTimeLine and endTimeValue,"End",Color.RED,Curve.SHORT_DASH);

#Display RSI Chart Label
AddLabel(showRsiChartLabel, "RSI: " + Round(rsi, rsiLabelDecimals), if rsi < over_Sold then RSI.color("OverSold") else if rsi > over_Bought then RSI.color("OverBought") else RSI.color("Normal"));

#Plot moving rsiLine across chart at current RSI level
plot rsiLine = if showHorRsiLine then HighestAll(if !IsNaN(RSI) and IsNaN(RSI[-1]) then RSI else Double.NaN) else Double.NaN;
rsiLine.SetDefaultColor(Color.BLACK);
rsiLine.AssignValueColor(if RSI > over_Bought then RSI.color("OverBought") else if RSI < over_Sold then RSI.color("OverSold") else RSI.color("Normal"));
rsiLine.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
rsiLine.SetLineWeight(1);

#Trending Color Average Line
plot avgRsi = if  showAvgRsi then MovingAverage(avgRsiAverageType, RSI, avgRsiLength) else Double.NaN;
avgRsi.DefineColor("UpTrend", Color.GREEN);
avgRsi.DefineColor("DownTrend", Color.RED);
avgRsi.SetLineWeight(2);
avgRsi.SetPaintingStrategy(PaintingStrategy.LINE);
avgRsi.SetStyle(Curve.FIRM);
avgRsi.AssignValueColor(if avgRsi > avgRsi[1] then avgRsi.Color("UpTrend") else avgRsi.Color("DownTrend"));

#END - RSI_Extreme

RSI_Extreme as both Upper and Lower indicators with all features enabled...

dnj1xuG.png


RSI_Extreme as both Upper and Lower indicators with midlines and average line disabled in the Upper and RSI horizontal line and chart label disabled in the Lower...

LMZH6AS.png
 
Last edited:

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

@rad14733 Great tool, thank you! Have you incorporated a watchlist code for alerts or scanner for when breakouts occur? Or how are you alerted? txs
While I myself am newer, I have learned a lot from this group. Here is a screenshot of a basic scanning of the indicator. First, you have to load your study and choose up the signal true. Next, you must load the RSI_Extreme from the study section into the scanner. Then follow the screen.
You can see results behind the scanner section
Jj9jwGw.png
 
@Miami51961 One thing to keep in mind is that, if memory serves me correctly, the breakout signals in this indicator fire as soon as there is a crossover rather than a crossback as the standard RSI breakouts function... This could be confusing, just as Buy The Dip can be, because there can be further directional movement after the indicator fires a signal... Just something to keep in mind...
 
@Miami51961 One thing to keep in mind is that, if memory serves me correctly, the breakout signals in this indicator fire as soon as there is a crossover rather than a crossback as the standard RSI breakouts function... This could be confusing, just as Buy The Dip can be, because there can be further directional movement after the indicator fires a signal... Just something to keep in mind...
Thanks, RAD14733. I did see that when I checked the results. I also see that with BTD as well. But like all scans, they warn us when something might happen or is setting up, which is what I was looking for. Still learning to clarify my postings better. Waiting for a confirmation day or other way for reversal and trends is always good.
Thaks for mentioning this point
 
@Miami51961 If you want to scan for uptrend crossovers you could just use something like "rsi crosses above avgRsi" or "rsi crosses above over_Sold"... You could also add additional criteria related to current or previous RSI levels... There is a lot of flexibility due to the number of plots to choose from...
 
@Miami51961 If you want to scan for uptrend crossovers you could just use something like "rsi crosses above avgRsi" or "rsi crosses above over_Sold"... You could also add additional criteria related to current or previous RSI levels... There is a lot of flexibility due to the number of plots to choose from...
Thanks for the information. I Will have to test them out
 
The indicators that you script have kept me out of serious trouble.
Tis better to have not traded on some days than to have traded all day and lost it all.
 
@PsycholoJackal When boolean arrows are used they plot at the price values, even if they are used in a lower indicator. They need to be assigned to a plot in the indicator itself to avoid this. Do something like the below code -

Code:
plot UpArrow = if RSI crosses above AvgRSI then AvgRSI else Double.NaN;
UpArrow.setsaintingstrategy(paintingstrategy.arrow_up);

plot DownArrow = if RSI crosses below AvgRSi then AvgRSI else Double.NaN;
DownArrow.setsaintingstrategy(paintingstrategy.arrow_down);
 
Actually, now that you posted that it reminded me, on true you need to use either the rsi or avgRsi value... Just posting as you were...
Hey Rad. So, I've been using RSI_Extreme on the phone for the past couple of weeks, now I've jumped on PC and noticed that this indicator on PC does not update in real time as quickly as it would on mobile. Only way for it to update is if I switch the ticker to a different one and then switch back which refreshes the charts/inidcators. I use the 10 minute chart and I can see other indicators like the CCI updating immediately on PC. What I mean is the avgRSI crossing the RSI which doesn't those 2 lines do not move to perform the cross as it would show on the phone in real time. Is there something I can do to fix it? I haven't made any changes to the script.
 
Last edited:
Hey Rad. So, I've been using RSI_Extreme on the phone for the past couple of weeks, now I've jumped on PC and noticed that this indicator on PC does not update in real time as quickly as it would on mobile. Only way for it to update is if I switch the ticker to a different one and then switch back which refreshes the charts/inidcators. I use the 10 minute chart and I can see other indicators like the CCI updating immediately on PC. What I mean is the avgRSI crossing the RSI which doesn't those 2 lines do not move to perform the cross as it would show on the phone in real time. Is there something I can do to fix it? I haven't made any changes to the script.

Are you sure you don't have a corrupt chart panel...??? I have it running on up to 10 charts or more at a time on my laptop, and on multiple charts on two PC's, and all update in real-time without issue... I'll try to observe closer next week but have been watching it most of this week along with a couple other indicators I've been playing with...
 
@PsycholoJackal because what you are saying is not a complaint heard of on the TOS platform, @rad14733 is trying to deduce why it would be happening to you alone. Chart panels in an app can get corrupted. Here is a shared link to a chart panel of mine:
SHARED LINK: http://tos.mx/59wZUbm
See more:
How To Import A Shared Link

Import my panel, customize it to look just like yours and see if the problem still occurs.
 
Hi Rad, this is great indicator, but I am not able to drag the RSI extreme on the price. Can you please advise how to do it? I put declare upper, I was able to see the indicator but it moved the price lower, price and RSI extreme did not overlap.
 
@majidg If Drag & Drop doesn't work you can simply use the Up/Down arrow icons on the right side of the indicator line to move it... Also make sure your chart is set to Auto rather than Manual under the Price Axis Settings icon in the upper right corner of your chart panel... You can also find the setting on the Price Axis tab within the Chart Settings panel by clicking on the cog/gear icon at the top of your chart...
 
I try to drag the RSI to the Upper Chart and I won't be able to plot that to the candle chart. I don't know what I am doing wrong. :(

How to add or if possible to add Alert when RSI crosses 50 lines either up or down? Thank you
 
Last edited by a moderator:
@PsycholoJackal When boolean arrows are used they plot at the price values, even if they are used in a lower indicator. They need to be assigned to a plot in the indicator itself to avoid this. Do something like the below code -

Code:
plot UpArrow = if RSI crosses above AvgRSI then AvgRSI else Double.NaN;
UpArrow.setsaintingstrategy(paintingstrategy.arrow_up);

plot DownArrow = if RSI crosses below AvgRSi then AvgRSI else Double.NaN;
DownArrow.setsaintingstrategy(paintingstrategy.arrow_down);
it s code error
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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