Relative Strength Index
systemic:core-rsiIndicatorsfunction1 crInputs
| Name | Type | Description |
|---|---|---|
| Window | integer | The **Window** parameter sets the lookback period for the RSI calculation—the number of periods used to compute average gains and losses. |
| Price | floatarray | The **Price** input accepts a time series of numerical values representing the prices you want to analyze. Typically, this is the **closing price** of an asset, though any consistent price measure (open, high, low, VWAP, etc.) can be used. |
Outputs
| Name | Type | Description |
|---|---|---|
| RSI | floatarray | The **RSI** output is a time series of values ranging from **0 to 100**, matching the length of your input price data. Each value represents the Relative Strength Index at that point in time. |
The Relative Strength Index (RSI) is one of the most powerful and widely used momentum oscillators in technical analysis. Created by J. Welles Wilder Jr. and introduced in his seminal 1978 book New Concepts in Technical Trading Systems, the RSI measures the velocity and magnitude of price movements to identify overbought and oversold conditions.
Unlike price itself, which can trend indefinitely, RSI is bounded between 0 and 100—making it immediately interpretable and comparable across any asset, timeframe, or market condition.
Where RS (Relative Strength) is the ratio of smoothed average gains to smoothed average losses:
Understanding RSI: The Intuition
At its core, RSI asks a simple but profound question: "How strong are the bulls compared to the bears?"
- When prices consistently rise, gains accumulate and losses diminish → RS increases → RSI approaches 100
- When prices consistently fall, losses accumulate and gains diminish → RS approaches 0 → RSI approaches 0
- When buying and selling pressure are balanced → RS ≈ 1 → RSI ≈ 50
flowchart TD
subgraph Input["📊 Price Data"]
P["Closing Prices"]
end
subgraph Changes["Δ Price Changes"]
D["Calculate Daily Changes<br/>ΔP = Pₜ − Pₜ₋₁"]
end
subgraph Separate["Separate Movements"]
G["Gains: Δ > 0"]
L["Losses: Δ < 0"]
end
subgraph Smooth["Wilder Smoothing"]
AG["Average Gain"]
AL["Average Loss"]
end
subgraph Calculate["RSI Calculation"]
RS["RS = Avg Gain / Avg Loss"]
RSI["RSI = 100 − 100 / 1 + RS"]
end
P --> D
D --> G & L
G --> AG
L --> AL
AG & AL --> RS --> RSI
The Mathematics in Detail
Let's walk through the RSI calculation step by step, ensuring you understand not just the what, but the why.
Step 1: Calculate Daily Price Changes
For each period , compute the change from the previous period:
Step 2: Separate Gains and Losses
We then separate upward movements (gains) from downward movements (losses):
Note: Losses are expressed as positive values. A price drop of $5 produces a Loss of 5, not -5.
Step 3: Apply Wilder's Smoothing
This is where RSI differs from simpler moving averages. Wilder's smoothing is a special form of exponential moving average (EMA) with a smoothing factor :
First value (Simple Average):
Subsequent values (Wilder Smoothing):
This formula gives previous values more weight, creating a smooth, less erratic indicator. Unlike a simple moving average, Wilder's smoothing remembers all past data—not just the last periods.
Step 4: Calculate RSI
Edge Case: If Average Loss = 0 (all prices rose), RSI = 100. If Average Gain = 0 (all prices fell), RSI = 0.
RSI Zones and Interpretation
The RSI scale naturally divides into meaningful zones:
| RSI Range | Zone | Interpretation |
|---|---|---|
| 70–100 | 🔴 Overbought | Strong bullish momentum; potential exhaustion. Watch for reversal signals. |
| 50–70 | 🟢 Bullish | Upward momentum dominates. Trend followers stay long. |
| 30–50 | 🟠 Bearish | Downward momentum dominates. Trend followers stay short or in cash. |
| 0–30 | 🔵 Oversold | Strong bearish momentum; potential exhaustion. Watch for bounce signals. |
The 50 Line: The Momentum Divider
The 50 level is the equilibrium point—gains and losses are balanced. Think of it as the "momentum equator":
- RSI > 50: Bulls are winning more battles than bears
- RSI < 50: Bears are winning more battles than bulls
- RSI crossing 50: A potential shift in the balance of power
flowchart LR
subgraph Bearish["🐻 Bear Territory"]
OS["Oversold<br/>RSI < 30"]
B["Bearish<br/>30 ≤ RSI < 50"]
end
subgraph Neutral["⚖️ Equilibrium"]
EQ["RSI = 50"]
end
subgraph Bullish["🐂 Bull Territory"]
BU["Bullish<br/>50 < RSI ≤ 70"]
OB["Overbought<br/>RSI > 70"]
end
OS --> B --> EQ --> BU --> OB
Adjusting RSI Thresholds for Different Markets
The classic 30/70 thresholds were designed for traditional stock markets. Different markets may require adjustments:
| Market Type | Suggested Oversold | Suggested Overbought | Rationale |
|---|---|---|---|
| Stocks (normal) | 30 | 70 | Classic Wilder thresholds |
| Strong uptrend | 40 | 80 | Overbought persists longer in bull markets |
| Strong downtrend | 20 | 60 | Oversold persists longer in bear markets |
| Cryptocurrency | 20 | 80 | Higher volatility requires wider bands |
| Forex (major pairs) | 30 | 70 | Classic thresholds work well |
Pro Tip: Rather than changing thresholds arbitrarily, observe where your specific asset tends to reverse. Historical backtesting reveals optimal zones for each instrument.
Window (Lookback Period) Selection
The window parameter determines how many periods are used in the RSI calculation. This is a critical choice:
| Window | Sensitivity | Best For |
|---|---|---|
| 7 | Very High | Scalping, day trading, catching quick reversals |
| 9 | High | Short-term swing trading |
| 14 | Balanced ⭐ | Wilder's original—works well for most applications |
| 21 | Low | Position trading, filtering noise |
| 25+ | Very Low | Long-term trend analysis |
The Trade-off
flowchart LR
subgraph Short["Short Window 7-9"]
S1["✓ More signals"]
S2["✓ Faster response"]
S3["✗ More false signals"]
S4["✗ Whipsaws in choppy markets"]
end
subgraph Long["Long Window 21+"]
L1["✓ Fewer false signals"]
L2["✓ Smoother line"]
L3["✗ Slower to react"]
L4["✗ May miss opportunities"]
end
Short -.->|"Trade-off"| Long
Trading Strategies with RSI
Strategy 1: Classic Overbought/Oversold
The simplest and most intuitive RSI strategy:
| Signal | Condition | Action |
|---|---|---|
| Oversold bounce | RSI drops below 30, then rises back above 30 | Consider buying |
| Overbought reversal | RSI rises above 70, then falls back below 70 | Consider selling |
⚠️ Warning: In strong trends, RSI can remain overbought or oversold for extended periods. An asset in a powerful bull run may see RSI stay above 70 for weeks. Use this strategy in ranging markets, or combine with trend filters.
Strategy 2: RSI Divergence
Divergence occurs when price and RSI move in opposite directions—often a powerful reversal signal:
| Type | Price Action | RSI Action | Signal |
|---|---|---|---|
| Bullish Divergence | Lower low | Higher low | Selling pressure weakening → potential upward reversal |
| Bearish Divergence | Higher high | Lower high | Buying pressure weakening → potential downward reversal |
Divergence works because it reveals hidden shifts in momentum before they manifest in price.
Strategy 3: The 50-Line Cross
A trend-following approach:
- Bullish: RSI crosses above 50 → momentum shifting bullish, consider long positions
- Bearish: RSI crosses below 50 → momentum shifting bearish, consider short positions
This generates fewer signals than overbought/oversold but is more reliable for trend confirmation.
Strategy 4: Failure Swings (Andrew Cardwell's Method)
A failure swing is a pattern that provides early reversal signals without requiring divergence:
Bullish Failure Swing:
- RSI falls below 30 (oversold)
- RSI bounces above 30
- RSI pulls back but holds above 30
- RSI breaks above the prior bounce high → Buy signal
This pattern shows that bears couldn't push RSI back into oversold territory—a sign of returning strength.
Combining RSI with Other Indicators
RSI is powerful alone but becomes even more effective when combined with complementary indicators:
flowchart TD
subgraph Data["📈 Price Data"]
P["Closing Prices"]
end
subgraph Trend["Trend Filter"]
SMA["SMA-200<br/>Trend Direction"]
end
subgraph Momentum["Momentum"]
RSI["RSI-14<br/>Overbought/Oversold"]
end
subgraph Logic["🔀 Decision Logic"]
AND["AND Gate"]
C1["Price > SMA-200"]
C2["RSI crosses above 30"]
end
subgraph Signal["📍 Trade Signal"]
BUY["Buy Signal"]
end
P --> SMA & RSI
SMA --> C1
RSI --> C2
C1 & C2 --> AND --> BUY
Example System: Only buy when:
- Price is above the 200-period SMA (confirming uptrend)
- RSI crosses above 30 (oversold bounce in an uptrend)
This filters out oversold bounces in downtrends—which often fail.
Real-World Application: Sector Rotation
RSI excels at relative strength analysis across multiple assets. By comparing RSI values across sectors or assets, you can identify:
- Emerging leaders: Assets with rising RSI while others stagnate
- Weakening sectors: Falling RSI despite overall market strength
- Rotation opportunities: When RSI of asset A peaks while asset B is bottoming
This approach is used by institutional traders to shift allocations before major moves become obvious on price charts.
Common Pitfalls to Avoid
| Pitfall | Why It's Dangerous | Solution |
|---|---|---|
| Buying purely on RSI < 30 | Oversold can get more oversold | Wait for RSI to cross back above 30 |
| Shorting at RSI > 70 | Overbought can persist in strong trends | Confirm with trend analysis |
| Using one timeframe | Miss the bigger picture | Check higher timeframe RSI for context |
| Ignoring the trend | Mean reversion fails in trends | Combine with SMA or ADX |
Strengths and Limitations
✅ Strengths
- Bounded scale (0-100): Easy to interpret, comparable across assets
- Versatile: Works on any asset class and any timeframe
- Multiple uses: Overbought/oversold, divergence, trend confirmation
- Well-researched: Decades of backtesting and academic study
⚠️ Limitations
- Lagging indicator: Based on past prices, so it reacts to moves rather than predicts them
- False signals in trends: Can stay overbought/oversold for extended periods
- Requires confirmation: Best used with other indicators or price action
Indicator Assessment
%%{init: {"quadrantChart": {"titleFontSize": 14}, "themeVariables": {"quadrant1Fill": "#e8f5e9", "quadrant2Fill": "#fff3e0", "quadrant3Fill": "#ffebee", "quadrant4Fill": "#e3f2fd"}}}%%
quadrantChart
title RSI Indicator Assessment
x-axis Low Popularity --> High Popularity
y-axis Low Reliability --> High Reliability
quadrant-1 High potential
quadrant-2 Established
quadrant-3 Niche
quadrant-4 Widely used
Stocks: [0.90, 0.70]
Crypto: [0.80, 0.60]
| Dimension | Stocks | Crypto | Explanation |
|---|---|---|---|
| Popularity | 9/10 | 8/10 | One of the most widely used indicators globally; taught in virtually every technical analysis course |
| Reliability | 7/10 | 6/10 | Highly reliable in ranging markets; less so in strong trends where it can stay overbought/oversold |
| Complexity | 3/10 | 3/10 | Simple concept (measuring gain vs. loss strength); Wilder smoothing adds minor complexity |
| Versatility | 9/10 | 8/10 | Works across all timeframes, all asset classes; multiple strategies (divergence, crossover, zones) |
| Recent Interest | 7/10 | 8/10 | Evergreen indicator with steady interest; crypto traders particularly favor momentum indicators |
Further Reading
- RSI - Investopedia — Comprehensive introduction
- RSI Divergence Trading - Investopedia — Understanding divergence patterns
- Trading Divergence and Momentum - Investopedia — Advanced divergence strategies
- RSI Buy and Sell Signals - Investopedia — Practical trading applications
- Wilder, J.W. (1978). New Concepts in Technical Trading Systems — The original source