Define RSI before calculating it
The Relative Strength Index (RSI) is a momentum oscillator that measures the relative strength of recent price gains versus recent price losses. The core idea is simple: over a chosen time window, compare how much the price went up to how much it went down. RSI then converts that comparison into a number that typically ranges between 0 and 100.
RSI is not a prediction by itself. It is a transformation of price-change history into a bounded indicator value. That transformation depends on the exact calculation rules you choose (especially the lookback length and how you smooth gains and losses).
RSI calculation: formula and required data
To calculate RSI, you need a time-ordered price series. Most RSI implementations use a single price per period (commonly the closing price) and compute changes from one period to the next.
Step 1: Choose the lookback period (N)
Pick a window length N (for example, a common choice is 14). RSI calculations refer to this N when averaging gains and losses.
Step 2: Compute one-period changes
For each period t, compute the price change:
- Change(t) = Price(t) − Price(t−1)
From Change(t), split it into two non-negative components:
- Gain(t) = max(Change(t), 0)
- Loss(t) = max(−Change(t), 0)
So only upward changes contribute to Gain, and only downward changes contribute to Loss.
Step 3: Average gains and average losses
RSI needs average gain and average loss over the lookback window. Different RSI “flavors” exist, but the widely used approach uses smoothing rather than a simple average every time.
A common smoothing method is:
- AverageGain = smoothed average of Gain(t) over N
- AverageLoss = smoothed average of Loss(t) over N
The details of the smoothing matter because RSI will differ if you use:
- simple moving averages (recompute from scratch each period), versus
- Wilder-style smoothing (recursive, using the prior smoothed values).
If you want consistent results across tools, use the exact smoothing rule your calculator or dataset expects.
Step 4: Convert averages into RS, then RSI
Compute the relative strength ratio:
- RS = AverageGain / AverageLoss
Then convert to RSI:
- RSI = 100 − (100 / (1 + RS))
Two special cases are worth stating explicitly:
- If AverageLoss is 0 (no recent losses in the averaging window), RS becomes very large. In practice, RSI approaches 100.
- If AverageGain is 0 (no recent gains), RS becomes 0. In practice, RSI becomes 0.
How RSI “works” mathematically
RSI compares two averaged quantities that come from the same underlying price series:
- When recent periods contain more gains than losses (in a smoothed average sense), AverageGain is relatively large compared with AverageLoss, making RS large and RSI high.
- When recent periods contain more losses than gains, AverageLoss dominates, RS is small, and RSI falls.
The bounded output (roughly 0 to 100) is a conversion of the ratio AverageGain/AverageLoss into a scale that tends to emphasize changes in the balance between upward and downward movement.
Importantly, RSI is sensitive to how you define “change” (the price input and the sampling frequency). A minute-by-minute close series and a daily close series can produce different RSI curves even if the “calculation formula” is identical.
Evidence or example you can reproduce
Below is a small, self-contained example setup. The goal is not to match any specific platform, but to show the required inputs and intermediate values.
Assumptions:
- Use close-to-close changes.
- Choose N = 5.
- Use a smoothing method consistent with your reference implementation.
You start with prices for periods 0 through 5 (six prices total). For each t from 1 to 5:
- Compute Change(t) = Price(t) − Price(t−1).
- Compute Gain(t) and Loss(t) as max(Change, 0) and max(−Change, 0).
- Compute AverageGain and AverageLoss using your chosen averaging method over the last N periods.
- Compute RS = AverageGain / AverageLoss.
- Compute RSI = 100 − (100 / (1 + RS)).
To reproduce results independently, do the same calculation with the same N and smoothing rule. If your RSI differs from a tool you are comparing against, the mismatch almost always comes from one of these choices:
- N value (lookback length)
- price series input (close vs another source)
- handling of the early periods before N data are available
- smoothing method (simple vs recursive)
- edge-case handling when AverageLoss or AverageGain is 0
Limitations and failure modes to consider
Even though RSI has a clear formula, it can produce misleading interpretations when the underlying assumptions are not stable.
Limitation 1: RSI depends on the chosen N and smoothing
Changing N changes which part of the recent history influences the averages. Changing the averaging/smoothing method changes the weighting of older versus newer gains and losses. As a result, two RSI series computed from the same prices can differ.
Limitation 2: Data quality and series definition matter
If your price series has discontinuities (for example, gaps due to non-trading periods) or if you switch the data source mid-way, the computed gains and losses change. Since RSI is driven by period-to-period differences, even small changes in the input can alter RSI.
Limitation 3: Edge cases can distort intuition
When AverageLoss is extremely small, RS becomes very large, pushing RSI toward the upper bound. That can happen during persistent upward movement, but it can also happen when the loss data in the window become nearly zero. Similarly, persistent flat movement can make the interpretation less intuitive because gains and losses can both be near zero depending on implementation details.
Limitation 4: RSI does not ensure predictive accuracy
RSI is derived from historical changes. Historical relationships between RSI movements and future outcomes do not guarantee anything about future behavior. Costs, execution timing, and changing market structure can all affect what “future results” look like compared with what the indicator historically suggested.
Verification and what to check next
To verify RSI calculations independently, focus on reproducibility rather than interpretation:
- Confirm the exact price input used in your calculation (which price per period).
- Confirm N (lookback period).
- Confirm the averaging/smoothing method used to compute AverageGain and AverageLoss.
- Confirm how the first RSI values are handled before a full window exists.
- Confirm how the implementation handles cases where AverageLoss is 0 or AverageGain is 0.