RSI (Relative Strength Index) Calculator
How Is the RSI (Relative Strength Index) Calculated? A Comprehensive Guide
The Relative Strength Index (RSI) is one of the most widely used momentum oscillators in technical analysis. Developed by J. Welles Wilder Jr. and introduced in his 1978 book New Concepts in Technical Trading Systems, the RSI helps traders identify overbought or oversold conditions in traded assets.
Understanding the RSI Formula
The RSI calculation involves several steps that transform raw price data into a normalized oscillator that ranges between 0 and 100. Here’s the complete breakdown:
- Price Changes Calculation: For each period, calculate the difference between the current closing price and the previous closing price.
- Gain/Loss Separation: Separate these changes into positive (gains) and negative (losses) values.
- Average Gain/Loss: Calculate the average of gains and absolute values of losses over the lookback period.
- Relative Strength: Divide the average gain by the average loss to get the Relative Strength (RS).
- RSI Calculation: Apply the final formula: RSI = 100 – (100 / (1 + RS)).
The Complete RSI Calculation Process
Let’s examine each step in detail with practical examples:
1. Price Changes Calculation
For a 14-period RSI (the standard setting), you need at least 15 closing prices. The calculation begins by determining the price change between consecutive periods:
Price Change = Current Close – Previous Close
| Day | Closing Price | Price Change |
|---|---|---|
| 1 | $100.00 | – |
| 2 | $101.50 | +$1.50 |
| 3 | $100.75 | -$0.75 |
| 4 | $102.25 | +$1.50 |
| 5 | $101.00 | -$1.25 |
| … | … | … |
| 15 | $107.50 | +$1.25 |
2. Gain/Loss Separation
Positive changes represent gains, while negative changes represent losses. We’ll separate these into two columns:
| Day | Gain | Loss |
|---|---|---|
| 1 | – | – |
| 2 | $1.50 | $0.00 |
| 3 | $0.00 | $0.75 |
| 4 | $1.50 | $0.00 |
| 5 | $0.00 | $1.25 |
| … | … | … |
3. Average Gain and Average Loss
The initial average gain and average loss are simple arithmetic means of the first 14 periods (for a 14-period RSI):
Initial Average Gain = (Sum of Gains over 14 periods) / 14
Initial Average Loss = (Sum of Losses over 14 periods) / 14
For subsequent periods, Wilder introduced a smoothing technique:
Average Gain = [(Previous Average Gain) × 13 + Current Gain] / 14
Average Loss = [(Previous Average Loss) × 13 + Current Loss] / 14
4. Relative Strength Calculation
The Relative Strength (RS) is the ratio of the average gain to the average loss:
RS = Average Gain / Average Loss
5. Final RSI Formula
The RSI is then calculated using:
RSI = 100 – (100 / (1 + RS))
RSI Interpretation Guide
The RSI provides specific signals based on its value:
- Overbought (Typically >70): Suggests the asset may be overvalued and could experience a pullback. However, in strong trends, the RSI can remain in overbought territory for extended periods.
- Oversold (Typically <30): Indicates the asset may be undervalued and could bounce back. Like overbought conditions, oversold readings can persist in strong downtrends.
- Neutral (30-70): The asset is neither overbought nor oversold according to the RSI.
- Divergences: When price makes a new high/low but RSI doesn’t, it may signal potential trend reversals.
- Centerline Crosses: Crosses above 50 may indicate bullish momentum, while crosses below 50 may suggest bearish momentum.
| RSI Range | Interpretation | Typical Market Condition | Suggested Action |
|---|---|---|---|
| Above 80 | Extremely Overbought | Strong uptrend or parabolic move | Watch for reversal signals |
| 70-80 | Overbought | Uptrend may be losing steam | Consider taking profits |
| 50-70 | Bullish | Healthy uptrend | Look for buying opportunities |
| 30-50 | Bearish | Healthy downtrend | Look for shorting opportunities |
| 20-30 | Oversold | Downtrend may be exhausting | Watch for reversal signals |
| Below 20 | Extremely Oversold | Strong downtrend or capitulation | Watch for reversal signals |
Practical Applications of RSI
Professional traders use RSI in various ways:
- Trend Confirmation: RSI can confirm the strength of a trend. In uptrends, the RSI tends to stay above 50, while in downtrends it stays below 50.
- Divergence Trading: Regular divergence (price makes higher highs while RSI makes lower highs) suggests weakening momentum. Hidden divergence can signal trend continuation.
- Overbought/Oversold Signals: While not always precise timing tools, extreme RSI readings can indicate potential reversal points.
- RSI Range Shifts: In strong trends, RSI may shift its range (e.g., 40-80 in uptrends, 20-60 in downtrends).
- Failure Swings: When RSI crosses above 70 then pulls back, holds above 70, and then breaks below 70, it can signal a top (reverse for bottoms).
Common RSI Trading Strategies
Here are three effective RSI-based strategies used by professional traders:
1. RSI Divergence Strategy
Setup:
- Identify regular bullish divergence (price makes lower lows while RSI makes higher lows)
- Or regular bearish divergence (price makes higher highs while RSI makes lower highs)
- Look for confirmation with price action (e.g., bullish engulfing pattern, pin bar)
Entry:
- Enter long when price breaks above recent swing high after bullish divergence
- Enter short when price breaks below recent swing low after bearish divergence
Stop Loss:
- Place below recent swing low for long positions
- Place above recent swing high for short positions
Take Profit:
- 1:2 or 1:3 risk-reward ratio
- Or when RSI reaches opposite extreme (70 for longs, 30 for shorts)
2. RSI Range Shift Strategy
Setup:
- Identify strong trend where RSI stays consistently in overbought/oversold territory
- In uptrends, RSI often stays between 40-80
- In downtrends, RSI often stays between 20-60
Entry:
- Buy when RSI pulls back to 40-50 in uptrend
- Sell when RSI rallies to 50-60 in downtrend
Stop Loss:
- Below recent swing low for long positions
- Above recent swing high for short positions
3. RSI Failure Swing Strategy
Setup:
- RSI crosses above 70 then pulls back
- RSI then makes another push above 70 and fails
- RSI breaks below its most recent low point
Entry:
- Enter short when RSI breaks below its recent low point
- For long setups, reverse the conditions (RSI below 30)
Advanced RSI Concepts
Experienced traders often modify standard RSI applications:
1. Adjusting the Lookback Period
While 14 is standard, different periods serve different purposes:
- Shorter periods (5-10): More sensitive, generates more signals, but with more false positives. Useful for day trading.
- Longer periods (20-30): Less sensitive, fewer signals, but higher reliability. Useful for swing trading.
2. RSI Smoothing Techniques
Some traders apply additional smoothing to RSI:
- Exponential RSI: Uses exponential moving averages instead of simple moving averages in the calculation.
- Double-Smoothed RSI: Applies a moving average to the RSI line itself to reduce noise.
3. Combining RSI with Other Indicators
RSI works best when combined with:
- Moving Averages: Confirm trend direction (e.g., 200-day MA for overall trend)
- MACD: Confirm momentum shifts
- Bollinger Bands: Identify volatility contractions/expansions
- Volume Indicators: Confirm participation in price moves
Limitations of RSI
While powerful, RSI has important limitations:
- False Signals in Strong Trends: RSI can remain in overbought/oversold territory for extended periods during strong trends.
- Lagging Indicator: Like all momentum oscillators, RSI is based on past prices and doesn’t predict future moves.
- Parameter Sensitivity: Different lookback periods can give conflicting signals.
- Whipsaws in Choppy Markets: RSI can generate many false signals in ranging markets.
- Subjective Interpretation: What constitutes “overbought” or “oversold” can vary by asset and market conditions.
Historical Performance of RSI
Academic studies have examined RSI’s effectiveness:
| Study | Findings | Sample Size | Time Period |
|---|---|---|---|
| Lo, Mamaysky, Wang (2000) | Found that technical indicators including RSI had predictive power, especially when combined with volume | 6,000+ stocks | 1962-1996 |
| Sullivan, Timmer, White (1999) | RSI showed statistically significant predictive ability for S&P 500 returns over 1-5 day horizons | S&P 500 | 1987-1997 |
| Brock, Lakonishok, LeBaron (1992) | Simple technical rules including RSI-based strategies outperformed buy-and-hold in foreign exchange markets | 6 currencies | 1971-1989 |
| Menkhoff, Taylor (2007) | Found that professional traders’ use of RSI and other technical indicators improved forecast accuracy | 100+ traders | 2001-2005 |
Optimizing RSI Parameters
The standard 14-period RSI isn’t always optimal. Consider these adjustments:
1. Asset-Specific Optimization
Different assets exhibit different momentum characteristics:
- Stocks: Typically respond well to 14-period RSI
- Forex: Often benefits from shorter periods (9-12) due to higher liquidity
- Cryptocurrencies: May require longer periods (20+) due to extreme volatility
- Commodities: Often work well with 10-14 period RSI
2. Timeframe Considerations
Adjust RSI period based on your trading timeframe:
- Scalping (1-5 min charts): 5-8 period RSI
- Day Trading (15min-1hr charts): 9-12 period RSI
- Swing Trading (4hr-daily charts): 14-21 period RSI
- Position Trading (weekly-monthly): 20-30 period RSI
3. Market Regime Adaptation
Market conditions should influence your RSI settings:
- Trending Markets: Use longer periods to avoid whipsaws
- Ranging Markets: Shorter periods can help identify overbought/oversold levels
- High Volatility: Longer periods reduce false signals
- Low Volatility: Shorter periods may provide better signals
Frequently Asked Questions About RSI Calculation
1. Why does RSI use 14 periods as the default?
J. Welles Wilder originally used 14 periods because it represented approximately half a lunar cycle (28 days). He found this provided a good balance between responsiveness and smoothness. The number also works well mathematically as it’s divisible by 2 and 7, making calculations easier in the pre-computer era.
2. Can RSI be used for all financial instruments?
Yes, RSI can be applied to any financial instrument with price data: stocks, forex, commodities, cryptocurrencies, ETFs, and indices. However, the optimal parameters may vary by instrument. For example, cryptocurrencies often require longer lookback periods due to their extreme volatility.
3. How often should I adjust my RSI settings?
You should review your RSI settings whenever:
- You change trading timeframes
- Market volatility regimes shift significantly
- You switch to a different asset class
- Your backtesting shows the current settings underperforming
Many professional traders maintain multiple RSI settings for different market conditions.
4. Why does my RSI calculation sometimes differ from trading platforms?
Differences can occur due to:
- Data Source Variations: Different platforms may use slightly different closing prices
- Calculation Methods: Some platforms use exponential smoothing rather than Wilder’s smoothing
- Timezone Differences: Daily candles may close at different times
- Handling of Gaps: Some calculations include gap moves, others don’t
- Initialization Periods: How the first RSI values are calculated can vary
5. Can RSI be used for mean reversion strategies?
Yes, RSI is particularly effective for mean reversion strategies in ranging markets. The classic approach is:
- Identify when RSI reaches extreme levels (typically above 70 or below 30)
- Look for confirmation with price action (e.g., candlestick patterns)
- Enter trades expecting a reversion to the mean
- Set tight stop losses as these are counter-trend trades
However, mean reversion strategies using RSI perform poorly in strong trending markets, where RSI can remain in overbought/oversold territory for extended periods.
6. How does RSI differ from other momentum oscillators?
| Indicator | Range | Calculation Basis | Best For | Key Difference from RSI |
|---|---|---|---|---|
| Stochastic Oscillator | 0-100 | Price position within recent range | Identifying overbought/oversold in ranging markets | More sensitive to recent price extremes |
| MACD | Unbounded | Difference between two EMAs | Trend identification and momentum | Not range-bound like RSI |
| Williams %R | -100 to 0 | Price position within recent range | Short-term overbought/oversold | Inverted scale compared to RSI |
| CCI | Typically -100 to +100 | Price deviation from statistical mean | Identifying cyclical turns | Measures deviation rather than internal strength |
| ROC | Unbounded | Price change over period | Momentum measurement | Direct percentage change rather than ratio |
Conclusion: Mastering RSI Calculation and Application
Understanding how RSI is calculated provides deep insights into its behavior and limitations. The key points to remember:
- RSI measures the ratio of average gains to average losses over a specified period
- The standard 14-period setting works well for most applications but can be optimized
- RSI is most effective when combined with other technical tools and price action analysis
- Like all indicators, RSI has limitations and should not be used in isolation
- Backtesting RSI strategies across different market conditions is essential for reliable results
By mastering the calculation and proper application of RSI, traders can gain a significant edge in identifying potential trend reversals, confirming trend strength, and timing entries and exits with greater precision. The calculator above allows you to experiment with different RSI parameters and see how they affect the indicator’s readings with your own price data.