modhelius

Relative Strength

Relative strength is a ratio between two assets, most often a stock and a market average (index). This implementation uses the method described here and the second method described here to calculate its value: "To calculate the relative strength of a particular stock, divide the percentage change over some time period by the percentage change of a particular index over the same time period". This indicator oscillates around zero. If the value is greater than zero, the investment has been relatively strong during the selected period; if the value is less than zero, the investment has been relatively weak. The period and the comparative symbol can be set in the settings for the indicator (the defaults are 50 and SPX ), there you can also find an option to turn on a moving average.
Release Notes: Update to Pine Script Version 4 and add resolution to study.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Comments

SIR WHAT IS THE FUNCTION OF THE MOVING AVERAGE PERIOD IN RELATIVE STRENGTH AND WHAT IS THE IDEAL PERIOD FOR RELATIVE STRENGTH IN DAILY TIME FRAME?
+89 Reply
modhelius DEEP2711
@DEEP2711, The function of the moving average is to smooth out the curve, can be handy for volatile instruments. Regarding the ideal period, please refer to my answer to merababa100.
+33 Reply
Chandan18 modhelius
@modhelius, Good Morning brother..i m from INDIA....i used your this indicator and find it good. Here in this indicator we compare a stock versus index.

but there are multiple relative strong stocks.. and i want to compare all the relative strong among themselves. to find which stocks is most strongest.... just like we use currency meter in forex. WE COMPARE ALL CURRENCY AMONG THEMSELVES... TO KNOW WHICH IS STRONGEST.

CAN U WRITE A CODE WHERE I SELECT MULTIPLE STOCKS AND COMPARE THERE RELATIVE STRENGTH...IN SINGLE WINDOW. TO DO INTRADAY AND POSITIONAL TRADE.
Reply
You said the default period is 50..what is the significance of 50? which is the other best period?
+45 Reply
modhelius merababa100
@merababa100, There is no significance, it is just a default value. It is up to the user of the indicator to decide what is the best period for the his or her individual usage. This is just a tool, how people use it is not up to me to decide ;) The "best" period will most certainly differ between different instruments and different time frames, the only thing that probably can answer this is thorough back testing of your strategy based on this indicator.
+5 Reply
pranavto modhelius
@modhelius, is it possible not to define the period ? Basically, can RS indicator takes the left most value seen on the chart as the base value to calculate the RS
Reply
modhelius pranavto
@pranavto, TradingView does not support doing indicators in that way what I am aware of, so the answer is that this is currently not possible. Notice that I'm not an employee nor an associate with TradingView so I will not be able to fix this until TradingView supports this, so if you want this kind of behavior you shall first send a feature request to TradingView.
+4 Reply
mangis modhelius
@modhelius, Thanks for this awesome work, it is helping be as a beginner to learn charts. I assume the default period = 50 will take the data from last 50 days and then plot the strength of the stock against the compared index. Am I correct in my assumption?
+4 Reply
@mangis, That is correct (as long as your time frame is days, if it is weeks it will be the last 50 weeks and so on).
+5 Reply
mangis modhelius
@modhelius, Great. Thanks for the clarification. Is it possible to add RS rating to the script e.g similar to IBD RS rating. Just a request if feasible. Thanks again.
+4 Reply