OPEN-SOURCE SCRIPT
Relative Strength Leadership Engine v2.0

Relative Strength Leadership Engine v2.0OverviewThe Relative Strength Leadership Engine v2.0 is a context-first diagnostic tool designed to identify true market leadership. Instead of simple ratio lines, this script employs a multi-layered scoring model to determine if a symbol is truly outperforming its benchmark (e.g., SPY) or simply riding market beta.The Problem It SolvesMany relative strength indicators fail to distinguish between idiosyncratic leadership and market correlation. A stock might look strong simply because it is a high-beta names moving in lockstep with a rising index. This engine uses Pearson Correlation Filtering and Volatility Normalization to decouple these factors.How It Works (The Math)To ensure full transparency for the TradingView community, the "Leadership Score" (0–100) is calculated based on four proprietary technical pillars:Baseline Alignment (30 pts): Measures if the $Price / Benchmark$ ratio is above its 21-period EMA.Volatility-Normalized Momentum (25 pts): We calculate a Z-score of the RS slope and divide it by the asset's ATR % of price. This ensures momentum is measured by "clean" price action rather than high-beta volatility spikes.Beta-Decoupling (20 pts): Using ta.correlation, the script penalizes "Market Huggers." Points are awarded when a stock shows strength independent of the benchmark's immediate fluctuations.Freshness & Highs (25 pts): Points are awarded for proximity to 252-day relative strength highs, identifying stocks entering a "Power Zone" of leadership.Interpreting the StatesThe dashboard in the bottom-right identifies three distinct permission states:ENGAGE (Score 80+): Full leadership permission. The asset is outperforming with idiosyncratic strength and clean momentum (See FDX example in the gallery).OBSERVE (Score 50–79): Leadership is present but aging or overly correlated to the market (See MU example in the gallery).STAND DOWN (Score <50): Leadership is broken; the asset is a relative laggard (See CBLL example in the gallery).Technical FeaturesMulti-Timeframe Validation: Optional Weekly/Monthly RS confirmation to filter out "noise."Benchmark Timing Filter: A built-in gate that checks if the broader market (Benchmark) is in a "Risk-Off" regime.Non-Repainting: All security calls use lookahead=barmerge.lookahead_off to ensure historical accuracy.Customizable UI: Toggle the dashboard on/off via the "Style" menu for a cleaner workspace.DisclaimerThis script is an informational diagnostic tool and does not generate trade signals, entries, or exits. Educational use only.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que la republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que la republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.