OPEN-SOURCE SCRIPT
Sector RSI (Auto-Select)

This indicator measures the relative strength momentum of any stock against its most closely correlated sector ETF, using the Relative Strength Index (RSI).
Auto sector selection: The script computes correlations between your symbol’s short-term returns and all major SPDR sector ETFs (XLB, XLE, XLF, XLI, XLK, XLP, XLU, XLV, XLY, XTN). The sector with the highest correlation is automatically chosen as the benchmark.
Sector vs Symbol RSI: It calculates RSI (default 14-period) for both the chosen sector and the current chart’s symbol.
Display modes:
Line mode: Plots both RSIs with colored fill (red if the sector RSI is stronger, green if the symbol RSI is stronger).
Histogram mode: Shows the difference between Sector RSI and Symbol RSI as a column chart.
RSI bands: Standard 70/50/30 reference lines are available in line mode.
Status line: The selected sector’s ticker is shown on the TradingView status line so you always know which sector is being used.
Use Cases:
Identify whether a stock’s momentum is driven by its sector or if it’s showing independent relative strength.
Detect sector rotations: when the stock begins to outperform or underperform its sector on momentum basis.
Combine with absolute RSI levels (overbought/oversold) to filter signals.
Notes:
This tool infers sector membership via rolling correlation, not from static classification metadata. This means in some cases (e.g. diversified companies or news shocks) the “best” sector may not be the official one, but the one most correlated in the current market regime.
Use min positive correlation input to filter out weak matches and enforce a fallback (defaults to Technology XLK).
Auto sector selection: The script computes correlations between your symbol’s short-term returns and all major SPDR sector ETFs (XLB, XLE, XLF, XLI, XLK, XLP, XLU, XLV, XLY, XTN). The sector with the highest correlation is automatically chosen as the benchmark.
Sector vs Symbol RSI: It calculates RSI (default 14-period) for both the chosen sector and the current chart’s symbol.
Display modes:
Line mode: Plots both RSIs with colored fill (red if the sector RSI is stronger, green if the symbol RSI is stronger).
Histogram mode: Shows the difference between Sector RSI and Symbol RSI as a column chart.
RSI bands: Standard 70/50/30 reference lines are available in line mode.
Status line: The selected sector’s ticker is shown on the TradingView status line so you always know which sector is being used.
Use Cases:
Identify whether a stock’s momentum is driven by its sector or if it’s showing independent relative strength.
Detect sector rotations: when the stock begins to outperform or underperform its sector on momentum basis.
Combine with absolute RSI levels (overbought/oversold) to filter signals.
Notes:
This tool infers sector membership via rolling correlation, not from static classification metadata. This means in some cases (e.g. diversified companies or news shocks) the “best” sector may not be the official one, but the one most correlated in the current market regime.
Use min positive correlation input to filter out weak matches and enforce a fallback (defaults to Technology XLK).
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.