Direct answer
RSI and a moving average are both computed from a time series of prices, but they do it in different ways. A moving average smooths the price by averaging recent values over a chosen window. RSI (Relative Strength Index) converts recent upward and downward changes into a bounded 0–100 score using a lookback window and a specific smoothing method (often Wilder’s smoothing).
To calculate them accurately, you need (1) the price series used (e.g., close prices), (2) the time step or data frequency (e.g., daily bars), and (3) the indicator parameters (lookback length for RSI, window length and method for the moving average). After you choose these assumptions, both calculations are deterministic and can be independently verified by recomputing from the same input series.
Mechanism or definition
Moving average: what is being averaged
A moving average produces a smoothed value for each time step by averaging a fixed number of recent observations.
- Simple Moving Average (SMA): the arithmetic mean of the last N price values.
- Exponential Moving Average (EMA): a weighted moving average that assigns more weight to recent prices, defined through a smoothing factor.
Because different platforms may implement EMA details slightly differently, the important thing for verification is to use the same definition and parameters.
SMA formula
Let P_t be the chosen price at time t (commonly the close). For a window length N, the SMA at time t (when enough data exist) is:
SMA(t) = (P_t + P_{t-1} + … + P_{t-N+1}) / N
This means the first SMA value requires at least N price points, and subsequent SMA values slide forward by one time step.
EMA idea and common form
An EMA can be expressed recursively, using the previous EMA value and the current price. A commonly used form is:
EMA(t) = EMA(t−1) + α × (P_t − EMA(t−1))
where α is a smoothing factor determined from the chosen length N. A typical relationship is α = 2 / (N + 1), but some tools may use slightly different initialization or conventions. For independent checks, you must match the exact EMA definition and starting rule used by the calculator you are comparing against.
RSI: converting gains and losses into a 0–100 score
RSI measures the relative magnitude of recent upward versus downward price changes. The classic approach works with consecutive differences and separates them into gains and losses.
Let the price series be P_t. Define the change:
Δ_t = P_t − P_{t-1}
Then define:
- Gain_t = max(Δ_t, 0)
- Loss_t = max(−Δ_t, 0)
After that, RSI computes smoothed averages (or sometimes simple averages, depending on the variant) over a lookback length N.
Relative strength and RSI formula
Compute the average gain and average loss over the window (with the chosen smoothing method), then:
RS = AvgGain / AvgLoss
RSI = 100 − (100 / (1 + RS))
Two edge cases matter for correct computation:
- If AvgLoss = 0, then RS is infinite, and RSI is effectively 100.
- If AvgGain = 0, then RS = 0, and RSI is 0.
These cases occur when price changes show no losses or no gains within the lookback window under the chosen definition.
Wilder-style smoothing (common RSI convention)
A widely used RSI method applies Wilder’s smoothing to gains and losses:
- For the first average at time t = N, use simple averages of the first N gains and losses.
- Then update recursively afterward.
A common update rule is:
AvgGain(t) = (AvgGain(t−1) × (N−1) + Gain_t) / N
AvgLoss(t) = (AvgLoss(t−1) × (N−1) + Loss_t) / N
Once you have these averages, compute RSI using the RS and RSI formulas above.
As with EMA, the key for verification is that you match the exact smoothing and initialization behavior used by the tool you are testing.
Evidence or example (with explicit assumptions)
Assumptions for the example
Assume:
- You use close prices.
- You compute indicators on a bar series with one fixed time step.
- RSI uses lookback N = 14 and Wilder-style smoothing.
- The moving average is an SMA with window N = 20.
Now define a small illustrative price series for a moving average (values only for demonstration):
For times t = 1…20, suppose the close prices are P_1, P_2, …, P_20.
- The SMA(20) equals (P_1 + P_2 + … + P_20) / 20.
- The SMA(21) equals (P_2 + P_3 + … + P_21) / 20.
This sliding property is the core of moving-average calculation.
RSI calculation steps
To compute RSI at time t, you need:
- Differences Δ_t = P_t − P_{t−1}.
- Gains and losses Gain_t = max(Δ_t, 0) and Loss_t = max(−Δ_t, 0).
- Smoothed averages AvgGain(t) and AvgLoss(t) using the chosen smoothing rule.
- RS and RSI:
- RS = AvgGain / AvgLoss
- RSI = 100 − (100 / (1 + RS))
Even without plugging in numeric values, the verification logic is the same: if you start from the same P_t series, apply the same definitions, and use the same initial averages, you must obtain the same RSI results as the indicator implementation.
Limitations and risks
Indicator sensitivity to data conventions
Both RSI and moving averages are sensitive to calculation conventions:
- Choice of the input price (close, open, typical price, etc.).
- Data frequency and how missing bars are handled.
- Window length and smoothing method (especially RSI’s smoothing and EMA’s initialization).
If one implementation uses a different convention, the outputs can differ even when the formulas look similar.
Failure modes and edge cases
Material limitations include:
- Early-period behavior: before you have enough data points, RSI and moving averages may be undefined or computed with special initialization rules.
- Division by zero (RSI): if average losses are zero, RSI hits 100; if average gains are zero, RSI hits 0. These results can reflect “no variation” in the change series within the window, not necessarily market conditions in a broader sense.
- Overfitting to parameters: RSI and moving averages change when you adjust lengths. A model or interpretation that depends on one set of parameters may not generalize.
Misinterpretation risk
RSI is an oscillator constructed from relative gains and losses; a moving average is a smoothing of price. Neither is inherently a standalone proof about future price movement. Historical relationships (if someone claims they exist) do not establish that the same relationship will hold later.
Verification or next question
How to independently verify the calculations
To verify RSI and moving averages yourself:
- Use the same price series and time steps as the charting tool.