Developed by J. Welles Wilder and introduced in his 1978 book, New Concepts in Technical Trading Systems, the Relative Strength Index (RSI) is an extremely useful and popular momentum oscillator. The RSI compares the magnitude of a stock's recent gains to the magnitude of its recent losses and turns that information into a number that ranges from 0 to 100. It takes a single parameter, the number of time periods to use in the calculation. In his book, Wilder recommends using 14 periods.
The RSI's full name is actually rather unfortunate as it is easily confused with other forms of Relative Strength analysis such as John Murphy's "Relative Strength" charts and IBD's "Relative Strength" rankings. Most other kinds of "Relative Strength" stuff involve using more than one stock in the calculation. Like most true indicators, the RSI only needs one stock to be computed. In order to avoid confusion, many people avoid using the RSI's full name and just call it "the RSI."
To simplify our explanation of the formula, the RSI has been broken down into its basic components which are the RS, the Average Gain, and the Average Loss.
To calculate RSI values for a given dataset, first find the magnitude of all gains and losses for the 14 periods prior to the time where you wish to start the calculation. (Note: 14 is the standard number of periods used when calculating the RSI. If a different number is specified, just substitute that number in for "14" throughout this discussion.)
It is important to understand that the RSI is a "running" calculation and the accuracy of the calculation depends on how long ago the calculations started. The first RSI value is an estimate - subsequent values improve on that estimate. You should calculate at least 14 values prior to the start of any values that you will rely on - going back 28+ periods is even better.
To start the running calculation, the First Average Gain is calculated as the total of all gains during the past 14 periods divided by 14. Similarly, the First Average Loss is calculated as the total magnitude of all losses during the past 14 periods divided by 14. The next values for the "averages" are calculated by taking the previous value, multiplying it by 13, adding in the next Gain (or Loss), and then dividing by 14. This is Wilder's modified "smoothing" technique in action.
The RS value is simply the Average Gain divided by the Average Loss for each period.
Finally, the RSI is simply the RS converted into an oscillator that goes between zero and 100 using this formula: 100 - (100 / RS + 1).
Here's an Excel Spreadsheet that shows RSI calculation in action.
When the Average Gain is greater than the Average Loss, the RSI rises because RS will be greater than 1. Conversely, when the Average Loss is greater than the Average Gain, the RSI declines because RS will be less than 1. The last part of the formula ensures that the indicator oscillates between 0 and 100. Note: If the Average Loss ever becomes zero, RSI becomes 100 by definition.
Important Note: The more data points that are used to calculate the RSI, the more accurate the results. The smoothing factor is a continuous calculation that - in theory - takes into account all of the closing values in the data set. If you start an RSI calculation in the middle of an existing data set, your values will only approximate the true RSI value. SharpCharts uses at least 250 data points prior to the starting date of any chart (assuming that much data exists) when calculating its RSI values. To duplicate our RSI numbers, you'll need to use at least that much data also.
Wilder recommended using 70 and 30 and overbought and oversold levels respectively. Generally, if the RSI rises above 30 it is considered bullish for the underlying stock. Conversely, if the RSI falls below 70, it is a bearish signal. Some traders identify the long-term trend and then use extreme readings for entry points. If the long-term trend is bullish, then oversold readings could mark potential entry points.
Buy and sell signals can also be generated by looking for positive and negative divergences between the RSI and the underlying stock. For example, consider a falling stock whose RSI rises from a low point of (for example) 15 back up to say, 55. Because of how the RSI is constructed, the underlying stock will often reverse its direction soon after such a divergence. As in that example, divergences that occur after an overbought or oversold reading usually provide more reliable signals.
The DELL example shows a number of extreme readings as well as a negative divergence. In Oct-99, RSI reached oversold for a brief moment to mark the low around 38. The next extreme reading (overbought) occurred after a large advance that peaked in Dec-99. RSI reached overbought levels in late Dec-99 and moved below 50 by the second week of Jan-00. The next oversold reading occurred in Feb. for another brief moment and marked the low around 35. By the end of Feb-00, RSI moved back above 50 and into overbought territory in March. A negative divergence formed in March and marked the high in the upper fifties.
Calculate RSI for Nifty of any stock or index - http://niftyrsi.blogspot.com/