OPEN-SOURCE SCRIPT
Shift Share - Full Diagnostics & R2

📄 Shift Share: Full Diagnostics & R²
Indicator Purpose:
To perform a "Multivariate Regression" on a stock's returns to see what is driving the price.
█ THE FOUR PERFORMANCE COMPONENTS
The indicator breaks down every price movement into four distinct buckets:
* Market (Beta): Returns driven by the broad market (e.g., SPY).
* Sector (Beta): Returns driven by your specific industry (e.g., XLF for Banks).
* Interaction: Returns caused by the market and sector moving in tandem (synergy).
* Unique (Idiosyncratic): Returns purely specific to the company (news, earnings, management).
█ CORE LOGIC & MATH
The script uses Log Returns and a Rolling Window (default 60 days) to calculate:
* Rolling Beta: It calculates how sensitive the stock is to the Market, Sector, and Interaction over time. This isn't a static number; it adapts as the stock's relationship with the market changes.
* T-Stats: This is a statistical "truth detector." It checks if the relationship is mathematically significant or just "noise."
* R-Squared ($R^2$): A measure of "Model Confidence." An $R^2$ of 0.80 means 80% of the stock's movement is explained by the Market and Sector, while 20% is random or unique.
█ HOW TO INTERPRET THE OUTCOME
1. The Cumulative Lines (The Visual Chart)
* Total (White): The actual price performance of the stock.
* Unique (Red): This is the most important line for stock pickers. If the red line is trending up, the company is outperforming its peers regardless of the economy. If it's trending down, the company is "bleeding" value despite what the market is doing.
* Market/Sector (Blue/Orange): If these are the primary movers, the stock is a "Beta play"—it’s just a passenger on the macro boat.
2. The Diagnostics Table (The Data)
* Share %: Tells you what percentage of the total return was contributed by that specific source.
* [SIG] vs [n.s.]: * [SIG]: Statistically Significant. You can trust that this factor (e.g., the Sector) is actually driving the price.
* [n.s.]: Not Significant. The relationship is weak; the price moves are likely random noise.
* Model Confidence ($R^2$): If this is low (e.g., < 30%), the "Unique" component is high, meaning the stock is "decoupled" from the market and doing its own thing.
█ LIMITATIONS
* Lookback Bias: Because it uses a rolling window (60 bars), it may take time to "notice" a sudden change in a stock's behavior.
* ETF Choice: The accuracy depends entirely on choosing the correct Sector ETF in the settings. If you use a Tech ETF (XLK) for a Bank stock, the data will be meaningless.
Indicator Purpose:
To perform a "Multivariate Regression" on a stock's returns to see what is driving the price.
█ THE FOUR PERFORMANCE COMPONENTS
The indicator breaks down every price movement into four distinct buckets:
* Market (Beta): Returns driven by the broad market (e.g., SPY).
* Sector (Beta): Returns driven by your specific industry (e.g., XLF for Banks).
* Interaction: Returns caused by the market and sector moving in tandem (synergy).
* Unique (Idiosyncratic): Returns purely specific to the company (news, earnings, management).
█ CORE LOGIC & MATH
The script uses Log Returns and a Rolling Window (default 60 days) to calculate:
* Rolling Beta: It calculates how sensitive the stock is to the Market, Sector, and Interaction over time. This isn't a static number; it adapts as the stock's relationship with the market changes.
* T-Stats: This is a statistical "truth detector." It checks if the relationship is mathematically significant or just "noise."
* R-Squared ($R^2$): A measure of "Model Confidence." An $R^2$ of 0.80 means 80% of the stock's movement is explained by the Market and Sector, while 20% is random or unique.
█ HOW TO INTERPRET THE OUTCOME
1. The Cumulative Lines (The Visual Chart)
* Total (White): The actual price performance of the stock.
* Unique (Red): This is the most important line for stock pickers. If the red line is trending up, the company is outperforming its peers regardless of the economy. If it's trending down, the company is "bleeding" value despite what the market is doing.
* Market/Sector (Blue/Orange): If these are the primary movers, the stock is a "Beta play"—it’s just a passenger on the macro boat.
2. The Diagnostics Table (The Data)
* Share %: Tells you what percentage of the total return was contributed by that specific source.
* [SIG] vs [n.s.]: * [SIG]: Statistically Significant. You can trust that this factor (e.g., the Sector) is actually driving the price.
* [n.s.]: Not Significant. The relationship is weak; the price moves are likely random noise.
* Model Confidence ($R^2$): If this is low (e.g., < 30%), the "Unique" component is high, meaning the stock is "decoupled" from the market and doing its own thing.
█ LIMITATIONS
* Lookback Bias: Because it uses a rolling window (60 bars), it may take time to "notice" a sudden change in a stock's behavior.
* ETF Choice: The accuracy depends entirely on choosing the correct Sector ETF in the settings. If you use a Tech ETF (XLK) for a Bank stock, the data will be meaningless.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。