Skip to content

Indicator Formula

Technical Details — Relative Strength Index (RSI)

Section titled “Technical Details — Relative Strength Index (RSI)”

The Relative Strength Index (RSI) calculates momentum strength by measuring the ratio of average gains to average losses over a specified period, then transforming this ratio into a bounded oscillator (0-100).

Key Concepts:

  • Period (n): The lookback window for averaging gains and losses (typically 14)
  • RMA Smoothing: Running Moving Average that smooths gain/loss sequences
  • RS (Relative Strength): Ratio of average gain to average loss
  • Transformation: RS ratio converted to 0-100 bounded scale

Mathematical Derivation

Step 1 — Separate Price Changes into Gains and Losses

Section titled “Step 1 — Separate Price Changes into Gains and Losses”

Purpose: Isolate upward and downward price movements.

$$Gain[t] = \max(Close[t] - Close[t-1], 0)$$

$$Loss[t] = \max(Close[t-1] - Close[t], 0)$$

Where:

  • $$Close[t]$$ = Current closing price
  • $$Close[t-1]$$ = Previous closing price

What This Measures: Separated directional price changes


Step 2 — Calculate RMA of Gains and Losses

Section titled “Step 2 — Calculate RMA of Gains and Losses”

Purpose: Smooth gain and loss sequences using RMA.

$$AvgGain[t] = \frac{AvgGain[t-1] \times (n-1) + Gain[t]}{n}$$

$$AvgLoss[t] = \frac{AvgLoss[t-1] \times (n-1) + Loss[t]}{n}$$

Where:

  • $$n$$ = Period

What This Measures: Smoothed average of gains and losses


Step 3 — Calculate Relative Strength (RS)

Section titled “Step 3 — Calculate Relative Strength (RS)”

Purpose: Compute the ratio of average gains to average losses.

$$RS[t] = \frac{AvgGain[t]}{AvgLoss[t]}$$

What This Measures: The balance between buying and selling pressure


Step 4 — Transform RS to Bounded RSI Scale

Section titled “Step 4 — Transform RS to Bounded RSI Scale”

Purpose: Convert unbounded RS ratio into a 0-100 oscillator.

$$RSI[t] = 100 - \frac{100}{1 + RS[t]}$$

What This Measures: Bounded momentum oscillator



Compact Formula Summary

$$Gain[t] = \max(Close[t] - Close[t-1], 0)$$ $$Loss[t] = \max(Close[t-1] - Close[t], 0)$$ $$AvgGain[t] = \frac{AvgGain[t-1] \times (n-1) + Gain[t]}{n}$$ $$RS = AvgGain / AvgLoss$$ $$RSI = 100 - 100/(1+RS)$$

Default: Period = 14


Complete Calculation Example

With Period = 14, after 14 bars: Avg Gain = 0.2321, Avg Loss = 0.1071 RS = 0.2321 / 0.1071 = 2.17 RSI = 100 - 100/(1 + 2.17) = 68.46

Result: RSI = 68.46 — strong bullish momentum (above neutral 50)


Key Takeaways from the Example
  1. Multi-Step Process: RSI requires gain/loss separation, RMA smoothing, RS ratio, and bounded transformation
  2. Initialization Period: First RSI value appears at period n+1
  3. Bounded Nature: RSI stays between 0-100 regardless of RS magnitude
  4. Cross-Asset Comparability: RSI 74 has the same interpretation whether the asset trades at $10 or $50,000