OPEN-SOURCE SCRIPT
Relative Strength Beta-Adjusted

BETA-ADJUSTED RELATIVE STRENGTH INDICATOR
This indicator removes broad market influence from a stock's returns to reveal its true, standalone performance over time.
WHAT IT TRACKS:
• Idiosyncratic Return (True RS): The portion of a stock's daily return that cannot be explained by its Beta exposure to the benchmark.
• Cumulative RS Line: A running total of these residual returns, starting at 100, showing the stock's pure alpha trend.
HOW IT WORKS:
The indicator calculates a rolling Beta between your chart symbol and a benchmark (default: SPY), then computes the "expected return" — what the stock should have done based on market movement alone. The difference between the actual return and expected return is the idiosyncratic return. These residuals are accumulated bar by bar into a cumulative line, with a moving average overlay (EMA or SMA).
When the RS line is above the MA, the area fills to indicate positive alpha momentum. When below, the fill shifts to signal deteriorating stock-specific strength.
SETTINGS:
• Benchmark Symbol: Index or ETF to measure against (default: SPY)
• Beta Length: Rolling window for Beta calculation (default: 60)
• MA Type: EMA or SMA (default: EMA)
• MA Length: Smoothing period for the moving average (default: 21)
• Colors: Fully customizable RS line, MA line, and fill colors
USAGE:
Use this to separate genuine stock performance from market noise. A rising line means the stock is generating real alpha. A falling line means it is underperforming what its market sensitivity alone would predict.
The MA crossover helps identify shifts in alpha momentum:
• RS above MA: Stock-specific strength is trending positive — favorable for long positions
• RS below MA: Stock-specific strength is fading — exercise caution or look elsewhere
• Rising line in a falling market: Stock is holding up on its own merits despite broad weakness
• Falling line in a rising market: Stock is being masked by market tailwinds — underlying weakness present
Other potential uses to explore:
• Stock picking: Find stocks generating genuine alpha versus those simply riding a bull market
• Rotation signals: Spot turning points in true relative strength before they show on the price chart
• Sector comparison: Apply to sector ETFs to identify fundamental leaders versus laggers
• Risk management: Reduce exposure when the RS line rolls over, even if price looks stable
• Pair analysis: Compare RS lines across related stocks to find the strongest name in a group
• Other Markets: Such as Crypto Markets set Bitcoin as the benchmark and any altcoin as the chart symbol to measure true relative performance against BTC — useful for identifying altcoins generating genuine strength versus those simply following Bitcoin's momentum
Experiment with different Beta lengths and MA settings to match your trading timeframe and style.
If you discover effective ways to use this indicator, please share in the comments below — your insights could help other traders!
This indicator removes broad market influence from a stock's returns to reveal its true, standalone performance over time.
WHAT IT TRACKS:
• Idiosyncratic Return (True RS): The portion of a stock's daily return that cannot be explained by its Beta exposure to the benchmark.
• Cumulative RS Line: A running total of these residual returns, starting at 100, showing the stock's pure alpha trend.
HOW IT WORKS:
The indicator calculates a rolling Beta between your chart symbol and a benchmark (default: SPY), then computes the "expected return" — what the stock should have done based on market movement alone. The difference between the actual return and expected return is the idiosyncratic return. These residuals are accumulated bar by bar into a cumulative line, with a moving average overlay (EMA or SMA).
When the RS line is above the MA, the area fills to indicate positive alpha momentum. When below, the fill shifts to signal deteriorating stock-specific strength.
SETTINGS:
• Benchmark Symbol: Index or ETF to measure against (default: SPY)
• Beta Length: Rolling window for Beta calculation (default: 60)
• MA Type: EMA or SMA (default: EMA)
• MA Length: Smoothing period for the moving average (default: 21)
• Colors: Fully customizable RS line, MA line, and fill colors
USAGE:
Use this to separate genuine stock performance from market noise. A rising line means the stock is generating real alpha. A falling line means it is underperforming what its market sensitivity alone would predict.
The MA crossover helps identify shifts in alpha momentum:
• RS above MA: Stock-specific strength is trending positive — favorable for long positions
• RS below MA: Stock-specific strength is fading — exercise caution or look elsewhere
• Rising line in a falling market: Stock is holding up on its own merits despite broad weakness
• Falling line in a rising market: Stock is being masked by market tailwinds — underlying weakness present
Other potential uses to explore:
• Stock picking: Find stocks generating genuine alpha versus those simply riding a bull market
• Rotation signals: Spot turning points in true relative strength before they show on the price chart
• Sector comparison: Apply to sector ETFs to identify fundamental leaders versus laggers
• Risk management: Reduce exposure when the RS line rolls over, even if price looks stable
• Pair analysis: Compare RS lines across related stocks to find the strongest name in a group
• Other Markets: Such as Crypto Markets set Bitcoin as the benchmark and any altcoin as the chart symbol to measure true relative performance against BTC — useful for identifying altcoins generating genuine strength versus those simply following Bitcoin's momentum
Experiment with different Beta lengths and MA settings to match your trading timeframe and style.
If you discover effective ways to use this indicator, please share in the comments below — your insights could help other traders!
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。