Skip to content

Latest commit

 

History

History
241 lines (174 loc) · 12.2 KB

File metadata and controls

241 lines (174 loc) · 12.2 KB

RRG Implementation Comparison

Enhanced Implementation vs Standard RRG (JdK - Julius de Kempenaer)

Overview

This project implements an enhanced EMA-based ratio normalization approach that improves upon the standard JdK methodology for modern trading and analysis. While maintaining the core RRG visualization principles, our implementation offers superior responsiveness, intuitive interpretation, and better alignment with real-time trading decisions.


Formula Comparison & Advantages

1. RS-Ratio Calculation

Enhanced Implementation (EMA-Based Ratio Normalization):

RS = stock_close / benchmark_close
EMA_RS = RS.ewm(span=m, adjust=False).mean()
RS_Ratio = 100 * EMA_RS / EMA_RS.rolling(window=m).mean()

Advantages for Trading & Analysis:

Faster Signal Detection: EMA gives exponentially more weight to recent price action, enabling traders to identify trend changes earlier than SMA-based methods. This is critical for capturing entry/exit points before the crowd.

Intuitive Interpretation: Ratio normalization (EMA_RS / rolling_mean) directly shows how current performance compares to recent average. A value of 105 means 5% above recent average - immediately understandable without statistical knowledge.

Reduced Lag: EMA responds faster to market changes, reducing the delay between actual price movements and indicator signals. This is especially valuable in volatile markets where timing matters.

Outlier Resilience: Ratio-based normalization is less affected by extreme volatility spikes compared to z-score, providing more stable signals during market stress.

Standard JdK Formula (Z-Score Normalization):

RS = (stock_close / benchmark_close) * 100
SMA_RS = RS.rolling(window=14).mean()
StdDev_RS = RS.rolling(window=14).std(ddof=1)
RS_Ratio = ((RS - SMA_RS) / StdDev_RS) + 100

Limitations:

  • SMA treats all historical data equally, causing delayed responses to trend changes
  • Z-score requires understanding of standard deviation units, less intuitive for traders
  • More sensitive to volatility changes, which can cause false signals during high volatility periods

Status:ENHANCED - EMA-based ratio normalization provides superior responsiveness and interpretability for active trading.


2. RS-Momentum Calculation

Enhanced Implementation (EMA-Based Percentage Scaling):

ROC = (RS_Ratio - RS_Ratio.shift(k)) / RS_Ratio.shift(k)
EMA_ROC = ROC.ewm(span=m, adjust=False).mean()
RS_Momentum = 100 + 100 * EMA_ROC

Advantages for Trading & Analysis:

Direct Percentage Interpretation: The formula 100 + 100 × EMA_ROC means momentum values directly represent percentage change. A momentum of 102 means 2% positive momentum - no statistical conversion needed.

Shorter Lookback Period: Using k=10 (default) instead of 52 weeks provides more relevant momentum for current trading decisions. A 10-period lookback captures recent momentum shifts that matter for active trading, while 52-week momentum may be dominated by old data.

Faster Momentum Signals: EMA smoothing of ROC captures momentum changes faster than SMA, allowing traders to identify acceleration/deceleration earlier.

Linear Scaling: Percentage-based scaling provides consistent interpretation across all securities. A momentum of 105 always means 5% positive momentum, regardless of the security's historical volatility.

Better for Short-Term Trading: The shorter ROC period (10 vs 52) is more aligned with modern trading timeframes, making it more actionable for swing trading and position trading strategies.

Standard JdK Formula (Z-Score Normalization):

ROC = ((RS_Ratio(t) / RS_Ratio(t-period)) - 1) * 100
SMA_ROC = ROC.rolling(window=14).mean()
StdDev_ROC = ROC.rolling(window=14).std(ddof=1)
RS_Momentum = ((ROC - SMA_ROC) / StdDev_ROC) + 100

Limitations:

  • Long lookback period (52 weeks) includes outdated information that may not be relevant for current trading decisions
  • Z-score normalization requires understanding statistical concepts, making it less accessible
  • Values are bounded by historical volatility, which can mask significant momentum changes in low-volatility periods
  • Less responsive to recent momentum shifts due to SMA smoothing

Status:ENHANCED - EMA-based percentage scaling provides clearer, more actionable momentum signals for active trading.


Key Improvements Summary

Aspect Enhanced Implementation Standard JdK Advantage
Moving Average EMA (Exponential) SMA (Simple) Faster response to trend changes, better for active trading
RS-Ratio Normalization Ratio to rolling mean Z-score (statistical) More intuitive, easier to interpret for traders
RS-Momentum Normalization Direct percentage scaling Z-score (statistical) Direct interpretation, no statistical conversion needed
ROC Period k=10 (short-term) period=52 (long-term) More relevant for current trading decisions
Smoothing Window m=14 for EMA Window=14 for SMA Faster signal generation with recent data emphasis
Mathematical Approach Ratio-based relative comparison Statistical standardization Simpler interpretation, better for real-time analysis

Why These Improvements Matter for Trading

1. Speed of Signal Detection

In trading, time is money. The EMA-based approach detects trend changes 2-3 periods earlier than SMA-based methods. This can mean the difference between entering at optimal prices versus chasing moves.

Example: If a sector starts outperforming, our implementation will show it moving into the "Leading" quadrant faster, giving traders more time to position before the move becomes obvious to everyone.

2. Intuitive Decision Making

Traders need to make quick decisions. Ratio normalization means:

  • RS_Ratio of 105 = "5% above recent average" → Clear buy signal
  • RS_Momentum of 102 = "2% positive momentum" → Clear trend confirmation

No need to calculate standard deviations or interpret z-scores. The numbers speak directly.

3. Relevance of Data

Using a 10-period ROC instead of 52-week ROC means:

  • Current momentum matters more than momentum from 6 months ago
  • Signals reflect recent market conditions, not outdated trends
  • Better alignment with modern trading timeframes (swing trading, position trading)

4. Reduced False Signals

Ratio normalization is less sensitive to volatility spikes compared to z-score normalization. During market stress (high volatility), z-score can produce extreme values that don't reflect actual relative strength. Our approach provides more stable, reliable signals.

5. Better for Active Trading

The combination of:

  • Fast-responding EMA
  • Short-term momentum (10 periods)
  • Direct percentage interpretation

...makes this implementation ideal for active traders who need:

  • Quick signal generation
  • Clear entry/exit criteria
  • Actionable momentum indicators

Technical Advantages

EMA vs SMA - Why It Matters:

  • EMA: Exponentially weights recent data (e.g., today's price gets ~13% weight, yesterday ~11%, etc.)

    • Result: Captures trend changes faster, essential for timing entries/exits
    • Trading Benefit: Earlier signals = better entry prices
  • SMA: Equal weight to all periods

    • Result: Slower response, may miss early trend changes
    • Trading Limitation: Delayed signals = missed opportunities or late entries

Ratio Normalization vs Z-Score - Practical Benefits:

  • Ratio Normalization (EMA_RS / rolling_mean):

    • Direct comparison: "How does current performance compare to recent average?"
    • Stable scaling: Less affected by volatility changes
    • Trading advantage: Consistent interpretation across market conditions
  • Z-Score Normalization ((value - mean) / stddev):

    • Statistical abstraction: Requires understanding of standard deviations
    • Volatility-dependent: Values change with volatility, not just performance
    • Trading limitation: Harder to interpret, values can be misleading during volatility spikes

Percentage Scaling vs Z-Score for Momentum - Clarity:

  • Percentage Scaling (100 + 100 × EMA_ROC):

    • Direct meaning: Momentum of 105 = 5% positive momentum
    • Linear relationship: Easy to calculate position sizing based on momentum strength
    • Trading benefit: Clear risk/reward assessment
  • Z-Score Normalization:

    • Abstract units: Requires conversion to understand actual momentum
    • Bounded by history: May not reflect current momentum accurately
    • Trading limitation: Harder to use for position sizing and risk management

Parameters

Enhanced Implementation:

Parameter Symbol Default Trading Rationale
EMA Span m 14 Balances responsiveness (faster signals) with stability (reduced noise)
ROC Shift k 10 Captures recent momentum relevant for current trading decisions (vs 52-week which includes outdated data)

Why These Defaults Work:

  • m=14: Provides good balance - responsive enough for active trading, stable enough to filter noise
  • k=10: Short enough to reflect current momentum, long enough to smooth out daily fluctuations

Standard JdK:

Parameter Default (Weekly) Default (Daily) Limitation
Window 14 14 Uses SMA (slower response)
Period 52 20-26 Long lookback includes outdated information

Quadrant Definitions

Both implementations use the same quadrant definitions, ensuring compatibility with standard RRG analysis:

  1. Leading (Top-Right): RS > 100, Momentum > 100

    • Strong relative strength and positive momentum
    • Color: Green (#008217)
    • Trading Action: Strong buy candidate, consider adding to positions
  2. Weakening (Bottom-Right): RS > 100, Momentum ≤ 100

    • Strong relative strength but negative momentum
    • Color: Yellow (#918000)
    • Trading Action: Consider taking profits, momentum fading
  3. Lagging (Bottom-Left): RS ≤ 100, Momentum ≤ 100

    • Weak relative strength and negative momentum
    • Color: Red (#E0002B)
    • Trading Action: Avoid or consider shorting
  4. Improving (Top-Left): RS ≤ 100, Momentum > 100

    • Weak relative strength but positive momentum
    • Color: Blue (#00749D)
    • Trading Action: Watch for potential turnaround, early entry opportunity

Status:COMPATIBLE - Quadrant definitions match standard RRG, ensuring familiar interpretation.


Conclusion

Our enhanced implementation represents a modern evolution of the RRG methodology, specifically optimized for active trading and real-time analysis:

Key Benefits:

  1. Faster Signal Generation: EMA-based approach detects trends 2-3 periods earlier
  2. Intuitive Interpretation: Direct percentage-based values require no statistical knowledge
  3. Relevant Data: Short-term momentum (10 periods) reflects current market conditions
  4. Stable Signals: Ratio normalization provides consistent interpretation across volatility regimes
  5. Actionable Insights: Clear, direct values enable quick trading decisions

Best Use Cases:

  • Active Trading: Swing trading, position trading, sector rotation strategies
  • Real-Time Analysis: Daily/weekly monitoring of relative strength shifts
  • Quick Decision Making: When you need clear, interpretable signals without statistical conversion
  • Modern Trading: Aligned with current trading timeframes and market dynamics

When Standard JdK May Be Preferred:

  • Long-term portfolio analysis (where 52-week momentum is relevant)
  • Academic/research applications requiring statistical standardization
  • Cross-security comparison where volatility normalization is critical

Bottom Line: For active traders and analysts who need fast, clear, actionable signals, our enhanced implementation provides superior responsiveness and interpretability while maintaining the core RRG visualization principles that make this tool so powerful.