OPEN-SOURCE SCRIPT
Z-Score (Normal Distribution ) with Alerts

Statistical Edge: Z-Score (Normal Distribution) Indicator
Concept & Logic
The Z-Score Indicator is a statistical tool used to measure how many standard deviations a price is from its mean (Simple Moving Average). By applying the principles of Normal Distribution (The Gaussian Curve) to market data, this indicator identifies whether a price move is "normal" or "extreme" relative to its recent history.
In a theoretical Normal Distribution:
68.2% of data points fall within ±1 Standard Deviation (SD).
95.4% of data points fall within ±2 SD.
99.7% of data points fall within ±3 SD.
When the Z-Score crosses these thresholds, it indicates that the current price action is statistically rare, often signaling potential exhaustion or a high-momentum breakout.
Key Features
Z-Score Line (Blue): Tracks the real-time deviation of price from the mean.
±2.0 Threshold (Dashed Lines): Represents the 95% confidence interval. Prices reaching this zone are considered "Overextended" and often see a return to the mean (Mean Reversion).
±3.0 Threshold (Solid Lines): Represents the 99.7% extreme zone. Movements here are rare and suggest either an imminent sharp reversal or the start of a "Black Swan" parabolic trend.
Statistical Zones: Color-coded fills (Red for high extreme, Green for low extreme) for quick visual scanning.
How to Trade with Z-Score
Mean Reversion: Look for the Z-Score to penetrate the +2 or +3 levels and then cross back toward the zero line (Mean). This often signals that the "stretch" is over and price is returning to balance.
Trend Strength: A Z-Score that stays consistently above +2 (or below −2) without returning to zero indicates a very strong momentum trend. Do not fight the trend in these "fat tail" events.
Divergence: Watch for price making a higher high while the Z-Score makes a lower high at the +2 level; this suggests the momentum is weakening despite the price increase.
Technical Settings
Period (Length): The lookback period for calculating the Mean and Standard Deviation (Default: 20).
Source: Usually set to Close, but can be adjusted for different strategies.
Disclaimer
Financial markets do not always follow a perfect Normal Distribution (they often exhibit "Leptokurtosis" or fat tails). Statistical indicators should be used as a confluence tool alongside Price Action, Volume, and other technical analysis methods. Past performance does not guarantee future results.
Concept & Logic
The Z-Score Indicator is a statistical tool used to measure how many standard deviations a price is from its mean (Simple Moving Average). By applying the principles of Normal Distribution (The Gaussian Curve) to market data, this indicator identifies whether a price move is "normal" or "extreme" relative to its recent history.
In a theoretical Normal Distribution:
68.2% of data points fall within ±1 Standard Deviation (SD).
95.4% of data points fall within ±2 SD.
99.7% of data points fall within ±3 SD.
When the Z-Score crosses these thresholds, it indicates that the current price action is statistically rare, often signaling potential exhaustion or a high-momentum breakout.
Key Features
Z-Score Line (Blue): Tracks the real-time deviation of price from the mean.
±2.0 Threshold (Dashed Lines): Represents the 95% confidence interval. Prices reaching this zone are considered "Overextended" and often see a return to the mean (Mean Reversion).
±3.0 Threshold (Solid Lines): Represents the 99.7% extreme zone. Movements here are rare and suggest either an imminent sharp reversal or the start of a "Black Swan" parabolic trend.
Statistical Zones: Color-coded fills (Red for high extreme, Green for low extreme) for quick visual scanning.
How to Trade with Z-Score
Mean Reversion: Look for the Z-Score to penetrate the +2 or +3 levels and then cross back toward the zero line (Mean). This often signals that the "stretch" is over and price is returning to balance.
Trend Strength: A Z-Score that stays consistently above +2 (or below −2) without returning to zero indicates a very strong momentum trend. Do not fight the trend in these "fat tail" events.
Divergence: Watch for price making a higher high while the Z-Score makes a lower high at the +2 level; this suggests the momentum is weakening despite the price increase.
Technical Settings
Period (Length): The lookback period for calculating the Mean and Standard Deviation (Default: 20).
Source: Usually set to Close, but can be adjusted for different strategies.
Disclaimer
Financial markets do not always follow a perfect Normal Distribution (they often exhibit "Leptokurtosis" or fat tails). Statistical indicators should be used as a confluence tool alongside Price Action, Volume, and other technical analysis methods. Past performance does not guarantee future results.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.