OPEN-SOURCE SCRIPT
Sector Relative Strength

This indicator measures a stock's Real Relative Strength against its sector benchmark, helping you identify stocks that are outperforming or underperforming their sector peers.
The concept is based on the Real Relative Strength methodology popularized by the r/realdaytrading community.
Unlike traditional relative strength calculations that simply compare price ratios, this indicator uses a more sophisticated approach that accounts for volatility through ATR (Average True Range), providing a normalized view of true relative performance.
Key Features
Automatic Sector Detection
Automatically detects your stock's sector using TradingView's built-in sector classification
Maps to the appropriate SPDR Sector ETF (XLK, XLF, XLV, XLY, XLP, XLI, XLE, XLU, XLB, XLC)
Supports all 20 TradingView sectors
Sector ETF Mappings
The indicator automatically compares your stock against:
Technology: XLK (Technology Services, Electronic Technology)
Financials: XLF (Finance sector)
Healthcare: XLV (Health Technology, Health Services)
Consumer Discretionary: XLY (Retail Trade, Consumer Services, Consumer Durables)
Consumer Staples: XLP (Consumer Non-Durables)
Industrials: XLI (Producer Manufacturing, Industrial Services, Transportation, Commercial Services)
Energy: XLE (Energy Minerals)
Utilities: XLU
Materials: XLB (Non-Energy Minerals, Process Industries)
Communications: XLC
Default: SPY (for Miscellaneous or unclassified sectors)
Customizable Settings
Comparison Mode: Choose between automatic sector comparison or custom symbol
Length: Adjustable lookback period (default: 12)
Smoothing: Apply moving average to reduce noise (default: 3)
Visual Clarity
Green line: Stock is outperforming its sector
Red line: Stock is underperforming its sector
Zero baseline: Clear reference point for performance
Clean info box: Shows which ETF you're comparing against
How It Works
The indicator calculates relative strength using the following methodology:
Rolling Price Change: Measures the price movement over the specified length for both the stock and its sector ETF
ATR Normalization: Uses Average True Range to normalize for volatility differences
Power Index: Calculates the sector's strength relative to its volatility
Real Relative Strength: Compares the stock's performance against the sector's power index
Smoothing: Applies a moving average to reduce single-candle spikes
Formula:
Power Index = (Sector Price Change) / (Sector ATR)
RRS = (Stock Price Change - Power Index × Stock ATR) / Stock ATR
Smoothed RRS = SMA(RRS, Smoothing Length)
The concept is based on the Real Relative Strength methodology popularized by the r/realdaytrading community.
Unlike traditional relative strength calculations that simply compare price ratios, this indicator uses a more sophisticated approach that accounts for volatility through ATR (Average True Range), providing a normalized view of true relative performance.
Key Features
Automatic Sector Detection
Automatically detects your stock's sector using TradingView's built-in sector classification
Maps to the appropriate SPDR Sector ETF (XLK, XLF, XLV, XLY, XLP, XLI, XLE, XLU, XLB, XLC)
Supports all 20 TradingView sectors
Sector ETF Mappings
The indicator automatically compares your stock against:
Technology: XLK (Technology Services, Electronic Technology)
Financials: XLF (Finance sector)
Healthcare: XLV (Health Technology, Health Services)
Consumer Discretionary: XLY (Retail Trade, Consumer Services, Consumer Durables)
Consumer Staples: XLP (Consumer Non-Durables)
Industrials: XLI (Producer Manufacturing, Industrial Services, Transportation, Commercial Services)
Energy: XLE (Energy Minerals)
Utilities: XLU
Materials: XLB (Non-Energy Minerals, Process Industries)
Communications: XLC
Default: SPY (for Miscellaneous or unclassified sectors)
Customizable Settings
Comparison Mode: Choose between automatic sector comparison or custom symbol
Length: Adjustable lookback period (default: 12)
Smoothing: Apply moving average to reduce noise (default: 3)
Visual Clarity
Green line: Stock is outperforming its sector
Red line: Stock is underperforming its sector
Zero baseline: Clear reference point for performance
Clean info box: Shows which ETF you're comparing against
How It Works
The indicator calculates relative strength using the following methodology:
Rolling Price Change: Measures the price movement over the specified length for both the stock and its sector ETF
ATR Normalization: Uses Average True Range to normalize for volatility differences
Power Index: Calculates the sector's strength relative to its volatility
Real Relative Strength: Compares the stock's performance against the sector's power index
Smoothing: Applies a moving average to reduce single-candle spikes
Formula:
Power Index = (Sector Price Change) / (Sector ATR)
RRS = (Stock Price Change - Power Index × Stock ATR) / Stock ATR
Smoothed RRS = SMA(RRS, Smoothing Length)
オープンソーススクリプト
TradingViewの精神に則り、この作者はスクリプトのソースコードを公開しているので、その内容を理解し検証することができます。作者に感謝です!無料でお使いいただけますが、このコードを投稿に再利用する際にはハウスルールに従うものとします。
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、この作者はスクリプトのソースコードを公開しているので、その内容を理解し検証することができます。作者に感謝です!無料でお使いいただけますが、このコードを投稿に再利用する際にはハウスルールに従うものとします。
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。