RSI (Relative Strength Index) Calculator

RSI (Relative Strength Index) Calculator

Calculate the Relative Strength Index (RSI) for a given series of closing prices. The RSI is a momentum indicator used in technical analysis that measures the magnitude of recent price changes to evaluate overbought or oversold conditions in the price of a stock or other asset.

Enter a list of closing prices, separated by commas or spaces, and specify the lookback period (typically 14). The calculator will determine the RSI value for the *latest* price in your list.

Enter Price Data

Enter prices chronologically from oldest to newest.
Number of periods to consider (standard is 14).

Understanding the Relative Strength Index (RSI)

What is RSI?

The Relative Strength Index (RSI) is a popular momentum oscillator developed by J. Welles Wilder Jr. It measures the speed and change of price movements. RSI oscillates between zero and 100. Traditionally, RSI is considered overbought when above 70 and oversold when below 30. These levels can be adjusted based on the specific asset or market.

How is RSI Calculated?

The standard RSI calculation involves several steps:

1. **Calculate Price Changes:** Determine the difference between consecutive closing prices.

2. **Separate Gains and Losses:** Identify which changes are upward moves (gains) and which are downward moves (losses). Use the absolute value for losses.

3. **Calculate Average Gain and Average Loss:** Using the specified lookback period (N), calculate the average gain and average loss over the chosen period. Wilder's original method uses a smoothing process similar to an Exponential Moving Average (EMA):

  • *Initial Average:* Sum of gains/losses over the first N periods, divided by N.
  • *Subsequent Averages:* `Avg Gain = ((Previous Avg Gain) * (N - 1) + Current Gain) / N`
    `Avg Loss = ((Previous Avg Loss) * (N - 1) + Current Loss) / N`

4. **Calculate Relative Strength (RS):** Divide the Average Gain by the Average Loss: RS = Average Gain / Average Loss

5. **Calculate RSI:** Use the RS value in the final formula:

RSI = 100 - (100 / (1 + RS))

Note: If the Average Loss is 0, RS is considered infinite, and RSI is 100. If the Average Gain is 0, RS is 0, and RSI is 0.

RSI Calculation Examples

Click on an example to see the step-by-step calculation:

Example 1: Simple Calculation (Period 3)

Scenario: Calculate RSI for the last price with a small period.

1. Known Values: Prices = [10, 12, 11, 13, 14], Period (N) = 3.

2. Price Differences: `[+2, -1, +2, +1]` (from 10->12, 12->11, 11->13, 13->14)

3. Gains & Losses: Gains = `[2, 0, 2, 1]`, Losses (Abs) = `[0, 1, 0, 0]`

4. Calculation (at price 13, the 4th price): Need first N=3 differences: `+2, -1, +2`. Gains `[2,0,2]`, Losses `[0,1,0]`.

  • Initial Avg Gain (over 3 periods) = (2+0+2) / 3 = 4 / 3 ≈ 1.333
  • Initial Avg Loss (over 3 periods) = (0+1+0) / 3 = 1 / 3 ≈ 0.333
  • RS (at price 13) = 1.333 / 0.333 ≈ 4.0
  • RSI (at price 13) = 100 - (100 / (1 + 4.0)) = 100 - (100 / 5.0) = 100 - 20 = 80.0

5. Calculation (at price 14, the 5th price): Use smoothed averages from previous step.

  • Previous Avg Gain ≈ 1.333, Previous Avg Loss ≈ 0.333
  • Current change is +1 (Gain=1, Loss=0)
  • New Avg Gain = ((1.333 * 2) + 1) / 3 = (2.666 + 1) / 3 = 3.666 / 3 ≈ 1.222
  • New Avg Loss = ((0.333 * 2) + 0) / 3 = 0.666 / 3 ≈ 0.222
  • RS (at price 14) = 1.222 / 0.222 ≈ 5.505
  • RSI (at price 14) = 100 - (100 / (1 + 5.505)) = 100 - (100 / 6.505) ≈ 100 - 15.37 ≈ 84.63

Conclusion: The RSI for the latest price (14) with a period of 3 is approximately 84.63.

Example 2: No recent losses (Period 5)

Scenario: What happens when there are no recent losses?

1. Known Values: Prices = [50, 51, 52, 53, 54, 55], Period (N) = 5.

2. Price Differences: `[+1, +1, +1, +1, +1]`

3. Gains & Losses: Gains = `[1, 1, 1, 1, 1]`, Losses (Abs) = `[0, 0, 0, 0, 0]`

4. Calculation (at price 55, the 6th price): Need first N=5 differences: `+1, +1, +1, +1, +1`. Gains `[1,1,1,1,1]`, Losses `[0,0,0,0,0]`.

  • Initial Avg Gain (over 5 periods) = (1+1+1+1+1) / 5 = 5 / 5 = 1.0
  • Initial Avg Loss (over 5 periods) = (0+0+0+0+0) / 5 = 0 / 5 = 0.0
  • RS (at price 55) = 1.0 / 0.0 = Infinity
  • RSI (at price 55) = 100 - (100 / (1 + Infinity)) = 100 - 0 = 100.0

Conclusion: When there are only gains within the lookback period, the RSI approaches 100.

Example 3: No recent gains (Period 4)

Scenario: What happens when there are no recent gains?

1. Known Values: Prices = [20, 19, 18, 17, 16], Period (N) = 4.

2. Price Differences: `[-1, -1, -1, -1]`

3. Gains & Losses: Gains = `[0, 0, 0, 0]`, Losses (Abs) = `[1, 1, 1, 1]`

4. Calculation (at price 16, the 5th price): Need first N=4 differences: `-1, -1, -1, -1`. Gains `[0,0,0,0]`, Losses `[1,1,1,1]`.

  • Initial Avg Gain (over 4 periods) = (0+0+0+0) / 4 = 0 / 4 = 0.0
  • Initial Avg Loss (over 4 periods) = (1+1+1+1) / 4 = 4 / 4 = 1.0
  • RS (at price 16) = 0.0 / 1.0 = 0.0
  • RSI (at price 16) = 100 - (100 / (1 + 0.0)) = 100 - 100 = 0.0

Conclusion: When there are only losses within the lookback period, the RSI approaches 0.

Example 4: Using Period 14 (More realistic)

Scenario: Calculate RSI for the last price using the standard period.

1. Known Values: Prices = [50.2, 51.1, 50.5, 51.8, 52.3, 52.0, 53.1, 52.7, 53.5, 54.0, 53.8, 54.5, 54.2, 55.1, 55.5], Period (N) = 14.

2. Data Requirement: You need at least N+1 = 15 prices. We have 15 prices.

3. Calculation Steps: (This is complex to do by hand for N=14, but the calculator does this)

  • Calculate the 14 price differences from 50.2 -> 55.1.
  • Separate gains and losses for these 14 differences.
  • Calculate the initial average gain and average loss over these first 14 differences.
  • Use the initial averages and the 15th price change (55.1 -> 55.5, which is +0.4) to calculate the smoothed average gain and average loss for the latest price (55.5) using the EMA-like formula.
  • Calculate RS = Smoothed Avg Gain / Smoothed Avg Loss.
  • Calculate RSI = 100 - (100 / (1 + RS)).

4. Result (Calculated by Tool): Input these prices and N=14 into the calculator.

Expected Result: Around 65-75 range based on the recent upward trend.

Conclusion: The calculator provides the RSI for the final price based on the full series and period.

Example 5: Sideways Market (Period 10)

Scenario: Prices are trading within a narrow range.

1. Known Values: Prices = [25, 25.1, 24.9, 25.2, 25, 25.1, 24.8, 25.1, 25, 25.2, 24.9], Period (N) = 10.

2. Data Requirement: Need at least N+1 = 11 prices. We have 11 prices.

3. Calculation: The calculator processes the 10 differences between the first 11 prices.

  • Differences: [+0.1, -0.2, +0.3, -0.2, +0.1, -0.3, +0.3, -0.1, +0.2, -0.3]
  • Gains: [0.1, 0, 0.3, 0, 0.1, 0, 0.3, 0, 0.2, 0] Sum = 1.0
  • Losses (Abs): [0, 0.2, 0, 0.2, 0, 0.3, 0, 0.1, 0, 0.3] Sum = 1.1
  • Initial Avg Gain = 1.0 / 10 = 0.1
  • Initial Avg Loss = 1.1 / 10 = 0.11
  • RS = 0.1 / 0.11 ≈ 0.909
  • RSI = 100 - (100 / (1 + 0.909)) = 100 - (100 / 1.909) ≈ 100 - 52.38 ≈ 47.62

Conclusion: In a sideways market with roughly equal gains and losses over the period, RSI tends to hover around 50.

Example 6: Short Period (Period 5) - Volatile Data

Scenario: Using a shorter period makes RSI more sensitive to recent changes.

1. Known Values: Prices = [100, 105, 98, 102, 95, 110], Period (N) = 5.

2. Data Requirement: Need at least N+1 = 6 prices. We have 6 prices.

3. Calculation Steps: (Calculator handles the details)

  • Calculate the 5 differences from 100 -> 95: [+5, -7, +4, -7, +15]
  • Gains: [5, 0, 4, 0, 15]. Sum = 24. Avg Gain (Initial) = 24 / 5 = 4.8
  • Losses (Abs): [0, 7, 0, 7, 0]. Sum = 14. Avg Loss (Initial) = 14 / 5 = 2.8
  • RS (at price 95) = 4.8 / 2.8 ≈ 1.714. RSI ≈ 63.16
  • Current change from 95 -> 110 is +15. (Gain=15, Loss=0)
  • New Avg Gain = ((4.8 * 4) + 15) / 5 = (19.2 + 15) / 5 = 34.2 / 5 = 6.84
  • New Avg Loss = ((2.8 * 4) + 0) / 5 = 11.2 / 5 = 2.24
  • RS (at price 110) = 6.84 / 2.24 ≈ 3.054
  • RSI (at price 110) = 100 - (100 / (1 + 3.054)) = 100 - (100 / 4.054) ≈ 100 - 24.67 ≈ 75.33

Conclusion: A short period can make RSI react quickly to large moves, showing overbought (above 70) after the jump to 110.

Example 7: Longer Period (Period 21)

Scenario: Using a longer period makes RSI smoother and less sensitive.

1. Known Values: Use a longer price series (e.g., 22 prices) from a chart, Period (N) = 21.

2. Data Requirement: Need at least N+1 = 22 prices.

3. Calculation: The calculator performs the iterative smoothing over the 21 periods leading up to the last price.

4. Result (Calculated by Tool): Input 22 prices and N=21. Compare the result to N=14 for the same series - the RSI line will appear smoother.

Conclusion: A longer period generates RSI values that change more slowly, providing a broader view of momentum.

Example 8: Handling Zero Average Loss

Scenario: A simple sequence with no losses within the period.

1. Known Values: Prices = [10, 11, 12, 13], Period (N) = 3.

2. Data Requirement: Need at least N+1 = 4 prices. We have 4 prices.

3. Calculation (at price 13): Differences `[+1, +1, +1]`. Gains `[1,1,1]`, Losses `[0,0,0]`.

  • Initial Avg Gain = (1+1+1) / 3 = 1.0
  • Initial Avg Loss = (0+0+0) / 3 = 0.0
  • RS = 1.0 / 0.0 = Infinity
  • RSI = 100 - (100 / (1 + Infinity)) = 100 - 0 = 100.0

Conclusion: When Avg Loss is zero over the lookback period, RSI is 100.

Example 9: Handling Zero Average Gain

Scenario: A simple sequence with no gains within the period.

1. Known Values: Prices = [20, 19, 18, 17], Period (N) = 3.

2. Data Requirement: Need at least N+1 = 4 prices. We have 4 prices.

3. Calculation (at price 17): Differences `[-1, -1, -1]`. Gains `[0,0,0]`, Losses `[1,1,1]`.

  • Initial Avg Gain = (0+0+0) / 3 = 0.0
  • Initial Avg Loss = (1+1+1) / 3 = 1.0
  • RS = 0.0 / 1.0 = 0.0
  • RSI = 100 - (100 / (1 + 0.0)) = 100 - 100 = 0.0

Conclusion: When Avg Gain is zero over the lookback period, RSI is 0.

Example 10: Using Decimal Prices (Period 14)

Scenario: Calculate RSI with decimal prices and standard period.

1. Known Values: Prices = [150.34, 151.12, 150.88, 152.55, 153.01, 152.75, 153.99, 154.10, 153.80, 154.50, 155.25, 155.00, 156.15, 156.05, 157.50], Period (N) = 14.

2. Data Requirement: Need at least N+1 = 15 prices. We have 15 prices.

3. Calculation: The calculator will process these decimal values precisely using floating-point arithmetic.

4. Result (Calculated by Tool): Input these prices and N=14 into the calculator.

Expected Result: A value likely reflecting a moderate upward trend over this short series.

Conclusion: The calculator handles decimal price values correctly for accurate RSI computation.

Frequently Asked Questions about RSI

1. What does RSI stand for?

RSI stands for Relative Strength Index.

2. Who developed the RSI indicator?

RSI was developed by J. Welles Wilder Jr., first published in 1978.

3. What is the typical lookback period for RSI?

The most commonly used lookback period is 14 periods (e.g., 14 days on a daily chart, 14 hours on an hourly chart).

4. What do high and low RSI values indicate?

Traditionally, an RSI value above 70 indicates the asset is overbought (potentially due for a price correction downwards), while a value below 30 indicates the asset is oversold (potentially due for a price correction upwards).

5. Can the overbought/oversold levels be adjusted?

Yes, traders often adjust the levels (e.g., using 80 and 20) based on the volatility and characteristics of the specific asset they are analyzing.

6. How is "Relative Strength" calculated in RSI?

Relative Strength (RS) is calculated as the ratio of the average gain during up periods to the average loss during down periods over the specified lookback period.

7. Why does the calculation use smoothing (like EMA)?

Wilder's smoothing method (similar to EMA) is used to make the RSI line less erratic than a simple moving average calculation would produce, providing a smoother representation of momentum.

8. What is a divergence in RSI?

A divergence occurs when the price of an asset makes a new high or low, but the RSI does not confirm it by making a corresponding new high or low. This can signal a potential reversal.

9. Can RSI be used for signals other than overbought/oversold?

Yes, traders also look for centerline crossovers (RSI crossing 50), support and resistance levels on the RSI line itself, and divergences.

10. How many data points are needed for the calculator?

To calculate the RSI for the latest price with a lookback period of N, you need at least N+1 historical closing prices, including the latest price itself.

Ahmed mamadouh
Ahmed mamadouh

Engineer & Problem-Solver | I create simple, free tools to make everyday tasks easier. My experience in tech and working with global teams taught me one thing: technology should make life simpler, easier. Whether it’s converting units, crunching numbers, or solving daily problems—I design these tools to save you time and stress. No complicated terms, no clutter. Just clear, quick fixes so you can focus on what’s important.

We will be happy to hear your thoughts

Leave a reply

Cunits
Logo