OPEN-SOURCE SCRIPT

Relative Performance Indicator - TrendSpider Style

51
Relative Performance Indicator - TrendSpider Style
📈 Overview
This Relative Performance (RP) indicator measures how your stock is performing compared to a benchmark index, displayed as a percentile ranking from 0-100. Based on TrendSpider's methodology, it answers the critical question: "Is this stock a leader or a laggard?"
Unlike simple ratio charts, this indicator uses percentile ranking to normalize relative performance, making it easy to identify when a stock is showing exceptional strength (>80) or concerning weakness (<20) compared to its historical relationship with the benchmark.
✨ Key Features

Three Calculation Modes:

Quarterly: 3-month relative performance for swing trading
Yearly: Weighted 4-quarter performance for position trading
TechRank: Composite of 6 technical indicators for multi-factor analysis


Clean Visual Design:

Green fills above 80 (strong outperformance)
Red fills below 20 (significant underperformance)
Dotted median line at 50 for quick reference
Current value label for instant reading


Flexible Benchmarks:

Compare against major indices (SPY, QQQ, IWM)
Sector ETFs for within-sector analysis
Custom symbols for specialized comparisons


Built-in Alerts:

Strong performance zone entry (>80)
Weak performance zone entry (<20)
Median crossovers (50 level)



📊 How To Use
Buy Signals:

RP crosses above 80: Stock entering leadership status
RP holding above 60: Maintaining relative strength
RP rising while price consolidating: Accumulation phase

Sell/Avoid Signals:

RP drops below 50: Losing relative strength
RP below 20: Significant underperformance
RP falling while price rising: Bearish divergence

Sector Rotation:

Compare multiple assets to find strongest sectors
Rotate into high RP assets (>70)
Exit low RP positions (<30)

🎯 Reading The Values

80-100: Exceptional outperformance - Strong buy/hold
60-80: Moderate outperformance - Hold positions
40-60: Market perform - No edge
20-40: Underperformance - Caution/reduce
0-20: Severe underperformance - Avoid/exit

⚙️ Calculation Method

Calculates percentage performance of both your stock and the benchmark
Finds the performance differential
Ranks this differential against historical values using percentile analysis
Normalizes to 0-100 scale for easy interpretation

This percentile approach adapts to different market conditions and volatility regimes, providing consistent signals whether in trending or choppy markets.
💡 Pro Tips

For Growth Stocks: Use quarterly mode with QQQ as benchmark
For Value Stocks: Use yearly mode with SPY as benchmark
For Small Caps: Compare against IWM, not SPY
For Sector Analysis: Use sector ETFs (XLK, XLF, XLE, etc.)
Combine with Price Action: High RP + price breakout = powerful signal

⚠️ Important Notes

RP is relative, not absolute - stocks can fall with high RP if the market falls harder
Choose appropriate benchmarks for meaningful comparisons
Best used in conjunction with price action and volume analysis
Historical lookback period affects sensitivity (adjustable in settings)

🔧 Customization
Fully customizable visual settings, thresholds, calculation periods, and smoothing options. Adjust the normalization lookback period (default 252 days) to fine-tune sensitivity to your trading timeframe.
📌 Credit
Inspired by TrendSpider's Relative Performance implementation, adapted for TradingView with enhanced customization options and Pine Script v6 optimization.

Tags to include: relativeperformance, relativestrength, percentile, ranking, sectorrotation, benchmark, outperformance, trendspider, marketbreadth, strengthindicator
Category: Momentum Indicators / Trend Analysis
Feel free to modify this description to match your style or add any specific points you want to emphasize!

Pernyataan Penyangkalan

Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.