Module 1: RSI Foundations for Day Traders

How RSI Actually Works: The Math Behind the Indicator - Part 8

8 min readLesson 8 of 10

Welcome back, traders. In this extensive module on RSI Foundations, we've explored the conceptual underpinnings, the psychological aspects, and the practical application of the Relative Strength Index. Now, in this crucial Part 8, we're going to dive deep into the very core of RSI: the mathematics that drive its oscillations.

Understanding the formula isn't just an academic exercise. For the professional day trader, a thorough grasp of how RSI is calculated unlocks a deeper intuition for its movements. It allows you to anticipate divergences with greater precision, understand why certain price actions lead to specific RSI readings, and ultimately, to make more informed, higher-probability trading decisions. You'll move beyond simply seeing a line on a chart to understanding the forces shaping that line.

Deconstructing the RSI Formula: The Building Blocks

At its heart, the RSI is an oscillator, meaning it fluctuates between two extremes, typically 0 and 100. It's designed to measure the speed and change of price movements. The standard RSI calculation uses a 14-period lookback, but as day traders, we often adjust this to shorter periods like 7, 9, or 11 to capture more immediate market dynamics on lower timeframes (e.g., 1-minute, 5-minute charts).

Let's break down the formula step-by-step.

Step 1: Calculating Average Gains and Average Losses

The foundational components of RSI are the average gains and average losses over a specified period. Let's use the standard 14-period RSI for our initial explanation.

Average Gain (AG): This is the sum of all positive price changes (up-closes) over the last 'N' periods, divided by 'N'. Average Loss (AL): This is the sum of all negative price changes (down-closes) over the last 'N' periods, divided by 'N'.

Important Nuance: The Smoothing Mechanism

Here's where it gets interesting and where many misunderstandings arise. The initial calculation of AG and AL for the first 14 periods is a simple moving average. However, for all subsequent periods, a wilder's smoothing method (also known as an exponential moving average-like smoothing) is applied. This is critical because it gives more weight to recent data while still incorporating historical data, making the RSI a responsive yet relatively smooth indicator.

Let's illustrate with an example using a hypothetical 3-period RSI to keep the numbers manageable, but the principle applies to 14 periods.

Hypothetical Price Data (Closing Prices): Day 1: $100 Day 2: $102 (Gain: $2, Loss: $0) Day 3: $101 (Gain: $0, Loss: $1) Day 4: $104 (Gain: $3, Loss: $0) Day 5: $103 (Gain: $0, Loss: $1) Day 6: $106 (Gain: $3, Loss: $0)

Calculating for the First 'N' Periods (Initial 3 Periods):

  • Period 1 (Day 1 to Day 3):

    • Gains: Day 2 ($2) + Day 3 ($0) = $2
    • Losses: Day 2 ($0) + Day 3 ($1) = $1
    • Initial Average Gain (AG_initial) = $2 / 2 = $1 (Note: We only count the changes from Day 2 and Day 3 in a 3-period lookback, not Day 1 itself as it has no prior close)
    • Initial Average Loss (AL_initial) = $1 / 2 = $0.50

    Self-correction: For the very first N periods, the average gain is the sum of gains over N periods divided by N, and similarly for losses. Let's adjust the example for a 3-period RSI starting from Day 1 to Day 3.

    Corrected Initial 3-Period Calculation:

    • Day 1: $100 (Base)
    • Day 2: $102 (Gain: $2, Loss: $0)
    • Day 3: $101 (Gain: $0, Loss: $1)
    • Sum of Gains over 3 periods (Day 1 to Day 3): $2 (from Day 2) + $0 (from Day 3) = $2
    • Sum of Losses over 3 periods (Day 1 to Day 3): $0 (from Day 2) + $1 (from Day 3) = $1
    • AG_initial = $2 / 3 = $0.6667
    • AL_initial = $1 / 3 = $0.3333

Calculating for Subsequent Periods (Wilder's Smoothing):

This is where the magic happens. For subsequent periods (e.g., Day 4 onwards in our 3-period example), the formula changes:

  • New Average Gain (AG_new): ((Previous AG * (N - 1)) + Current Gain) / N
  • New Average Loss (AL_new): ((Previous AL * (N - 1)) + Current Loss) / N

Let's continue our example for Day 4, using N=3:

  • Day 4: Close $104 (Gain: $3, Loss: $0)
    • Previous AG (from Day 1-3) = $0.6667

    • Previous AL (from Day 1-3) = $0.3333

    • Current Gain = $3

    • Current Loss = $0

    • AG_Day4 = (($0.6667 * (3 - 1)) + $3) / 3

      • AG_Day4 = (($0.6667 * 2) + $3) / 3
      • AG_Day4 = ($1.3334 + $3) / 3
      • AG_Day4 = $4.3334 / 3 = $1.4445
    • AL_Day4 = (($0.3333 * (3 - 1)) + $0) / 3

      • AL_Day4 = (($0.3333 * 2) + $0) / 3
      • AL_Day4 = $0.6666 / 3 = $0.2222

Notice how the previous average is "carried forward" and weighted heavily, then the current period's gain/loss is added, and finally, it's averaged over N periods. This is what makes Wilder's smoothing so effective – it's a self-correcting, adapting average that smooths out jagged price action without being overly slow.

Practical Takeaway: This smoothing mechanism is why RSI doesn't jump wildly with every single price tick, even on short timeframes. It provides a more nuanced view of sustained momentum. When you see RSI trending strongly, it implies a consistent bias in gains or losses over the lookback period, not just a single large move.

Step 2: Calculating Relative Strength (RS)

Once we have our Average Gain (AG) and Average Loss (AL) for the current period, the next step is straightforward:

Relative Strength (RS) = Average Gain / Average Loss

Let's use our Day 4 AG and AL:

  • AG_Day4 = $1.4445
  • AL_Day4 = $0.2222
  • RS_Day4 = $1.4445 / $0.2222 = 6.50

Understanding RS:

  • If RS > 1, it means average gains are greater than average losses over the period, indicating upward momentum.
  • If RS < 1, it means average losses are greater than average gains, indicating downward momentum.
  • If RS = 1, average gains equal average losses, suggesting a balanced or consolidating market.

Crucial Caveat for AL = 0: What happens if there are no losses over the 'N' periods, making AL = 0? In this scenario, dividing by zero is undefined. Most charting platforms and RSI calculations will assign an extremely high value to RS (approaching infinity) or simply set RSI to 100. Conversely, if AG = 0, RS will be 0, and RSI will be 0. This is why you see RSI hit 100 or 0 during extremely strong, uninterrupted trends.

Step 3: Calculating the Relative Strength Index (RSI)

Finally, we convert the Relative Strength (RS) into an index that oscillates between 0 and 100:

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

Let's calculate RSI for Day 4:

  • RS_Day4 = 6.50
  • RSI_Day4 = 100 - (100 / (1 + 6.50))
  • RSI_Day4 = 100 - (100 / 7.50)
  • RSI_Day4 = 100 - 13.33
  • RSI_Day4 = 86.67

And there you have it! An RSI reading of 86.67 for Day 4, which is well into overbought territory (typically above 70). This aligns with our observation that Day 4 had a significant gain after a slight pullback.

Why this formula? This specific transformation ensures that:

  1. As RS approaches infinity (strong uptrend), RSI approaches 100.
    • Example: If RS = 9999, RSI = 100 - (100 / (1 + 9999)) = 100 - (100 / 10000) = 100 - 0.01 = 99.99
  2. As RS approaches 0 (strong downtrend), RSI approaches 0.
    • Example: If RS = 0.0001, RSI = 100 - (100 / (1 + 0.0001)) = 100 - (100 / 1.0001) = 100 - 99.99 = 0.01
  3. When RS = 1 (gains equal losses), RSI = 50.
    • RSI = 100 - (100 / (1 + 1)) = 100 - (100 / 2) = 100 - 50 = 50. This is why the 50-level is often considered the "midpoint" or equilibrium zone for RSI.

The Impact of 'N' (Lookback Period) on RSI Behavior

Now that we understand the math, let's explore how changing the 'N' period affects the RSI's output, a crucial adjustment for day traders.

  • Smaller 'N' (e.g., 7, 9 periods):

    • Effect: RSI becomes more sensitive and faster-moving. It will react more quickly to recent price changes, leading to more frequent entries into overbought/oversold territory.
    • Pros for Day Trading: Excellent for capturing short-term momentum shifts and potential scalp opportunities on 1-minute or 5-minute charts. It can provide earlier signals for trend exhaustion or reversal.
    • Cons for Day Trading: Prone to more "whipsaws" or false signals. A 7-period RSI on a 1-minute chart might hit 80 on a minor two-candle surge, only for the price to continue higher. Requires tighter stops and a good understanding of market context.
    • Example Use Case: A day trader focusing on high-frequency scalp trades in a fast-moving instrument like NQ futures might use a 7-period RSI on a 1-minute chart to identify quick overextensions for fade trades, combined with level analysis.
  • Larger 'N' (e.g., 14, 21 periods):

    • Effect: RSI becomes smoother and slower-moving. It filters out short-term noise, providing a more stable view of underlying momentum.
    • Pros for Day Trading: Reduces false signals, better for identifying more significant trend shifts or potential reversals on higher timeframes (e.g., 15-minute, 30-minute charts) that might be setting up for a multi-hour move.
    • Cons for Day Trading: Lagging indicator. Signals will be delayed compared to shorter-period RSIs, potentially causing missed entries or less optimal exit points for very short-term trades.
    • Example Use Case: A day trader looking for swing trades within the day or identifying major inflection points on SPY might use a 14-period RSI on a 15-minute chart to confirm trend strength or divergence from key support/resistance.

Practical Tip: Don't just pick one 'N'. Many professional day traders use multiple RSI periods simultaneously. For instance, a 5-period RSI on a 1-minute chart for entry timing, and a 14-period RSI on a 5-minute chart for overall trend confirmation or to identify larger divergences. This multi-timeframe, multi-RSI approach provides a more holistic view.

The Mathematical Basis of RSI Divergences

Divergence is arguably the most powerful application of RSI for day traders. Now that you understand the math, you can see why divergences occur and what they truly signify.

Recall:

  • RSI measures the average speed and magnitude of gains vs. losses.
  • Price measures the absolute closing value.

A bullish divergence occurs when price makes a lower low, but RSI makes a higher low.

  • Mathematical Interpretation: Even though price printed a new low, the rate of decline (average losses) decreased, or the average magnitude of gains within that period was stronger relative to losses than during the previous low. This suggests selling pressure is weakening even as price is still being pushed down. The "teeth" of the selling are getting duller.

A bearish divergence occurs when price makes a higher high, but RSI makes a lower high.

  • Mathematical Interpretation: Despite price pushing to a new high, the rate of ascent (average gains) decreased, or the average magnitude of losses within that period was stronger relative to gains than during the previous high. This implies buying pressure is weakening, even as price is still being lifted. The "fuel" for the rally is diminishing.

Example: Bearish Divergence on ES Futures (5-minute chart)

Let's imagine ES futures are in a strong uptrend.

  • Price Action:
    • High 1: ES reaches 4850, then pulls back slightly.
    • High 2: After consolidating, ES pushes higher, reaching 4855. A new high!
  • RSI (14-period) Action:
    • RSI at High 1: When ES was at 4850, RSI was at 78.
    • RSI at High 2: When ES reached 4855, RSI only reached 72.

Mathematical Breakdown of the Divergence:

  • High 1 (RSI 78): This indicates that over the past 14 periods leading up to 4850, average gains were significantly higher than average losses, leading to a high RS value and thus a high RSI.
  • High 2 (RSI 72): Despite price making a new higher high to 4855, the RSI is lower. How can this be?
    • It means that during the 14 periods leading up to 4855, while there were still net gains, the average magnitude of those gains was less pronounced, or there were more significant periods of losses interspersed, compared to the run-up to 4850.
    • Perhaps the candles leading to 4855 had smaller bodies, more wicks, or more frequent small pullbacks within the 14-period window, even if the overall close was higher.
    • The "strength" of the buying pressure (as measured by the average gains) was weaker, even if the final price managed to creep higher due to inertia or a final push.

Actionable Strategy: Trading a Bearish Divergence in ES

Let's outline a specific trade plan for the ES example above:

  • Instrument: ES Futures
  • Timeframe: 5-minute chart
  • RSI Setting: 14 periods
  • Context: Strong uptrend, but showing signs of exhaustion near a key resistance level (e.g., 4860, previous day's high, or a daily pivot).
  1. Observation: Price makes a new high (4855), but the 14-period RSI makes a lower high (72 vs. 78). This is a confirmed bearish divergence.
  2. Confirmation (Optional but Recommended): Look for additional confirmation.
    • Candlestick Pattern: A bearish reversal candle at the new high (e.g., shooting star, engulfing pattern, bearish pin bar) on the 5-minute or even 1-minute chart.
    • Volume: Declining volume on the push to the new high, indicating less conviction from buyers.
    • Market Structure: Price breaking a short-term trendline on a lower timeframe (e.g., 1-minute).
  3. Entry
The Black Book of Day Trading Strategies
Free Book

The Black Book of Day Trading Strategies

1,000 complete strategies · 31 chapters · Full trade plans