OPEN-SOURCE SCRIPT
Z-Score Source Monitor

Z-Score Source Monitor
What this script does:
Z-Score Source Monitor calculates a rolling Z-Score on any external indicator line connected via the source input. It answers one question: how statistically extreme is the current reading of any oscillating indicator relative to its recent history?
A Z-Score of 0 means the source is exactly at its rolling mean. A reading of ±1 is within normal range. A reading beyond ±2 occurs roughly 5% of the time statistically, and beyond ±3 less than 1% of the time. These are the levels where statistical exhaustion tends to occur.
What makes this script original:
Most Z-Score indicators on TradingView calculate the Z-Score on price. This script is built around a generic input.source — meaning it can calculate the Z-Score on any indicator plot, not just price. This makes it a universal statistical layer that can be placed on top of momentum oscillators, volume indicators, custom signals, or any other plotted line.
The volatility calculation uses EWMA (Exponentially Weighted Moving Average) variance rather than a fixed rolling standard deviation. This means the script adapts faster to changes in the statistical behavior of the source, without waiting for the full lookback window to shift. In fast-moving or regime-changing markets this produces a more responsive and accurate measure of statistical extension.
How to use it:
Connect any external indicator plot to the Source input. The script will calculate and display:
Smoothed Z-Score as histogram and line, color-coded by zone
Raw Z-Score as a reference behind the smoothed line
Reference lines at ±1σ, ±2σ and ±3σ
Dashboard showing current Z-Score, zone classification, direction and raw Z value
The example chart uses the Fast Line from Bjorgum's TSI indicator as the source input, demonstrating how the Z-Score identifies statistical extremes on a momentum oscillator.
Settings
Source: connect any external indicator plot
Lookback: number of bars for the rolling mean (default 20)
EWMA Half-Life: controls how quickly the volatility measure adapts to recent behavior (default 15)
Z-Score Smoothing: EMA smoothing applied to the raw Z-Score to reduce noise (default 3)
How to read the zones:
Gray: neutral, source near its mean
Light blue / light orange: mild extension beyond ±1σ
Blue / red: statistically extended beyond ±2σ — observe closely
Dark blue / dark red: rare extreme beyond ±3σ
Important note:
This script is an observation tool. It identifies statistical extremes but does not generate buy or sell signals. Always use it as additional context alongside your own analysis. Past statistical extremes do not guarantee future reversals.
What this script does:
Z-Score Source Monitor calculates a rolling Z-Score on any external indicator line connected via the source input. It answers one question: how statistically extreme is the current reading of any oscillating indicator relative to its recent history?
A Z-Score of 0 means the source is exactly at its rolling mean. A reading of ±1 is within normal range. A reading beyond ±2 occurs roughly 5% of the time statistically, and beyond ±3 less than 1% of the time. These are the levels where statistical exhaustion tends to occur.
What makes this script original:
Most Z-Score indicators on TradingView calculate the Z-Score on price. This script is built around a generic input.source — meaning it can calculate the Z-Score on any indicator plot, not just price. This makes it a universal statistical layer that can be placed on top of momentum oscillators, volume indicators, custom signals, or any other plotted line.
The volatility calculation uses EWMA (Exponentially Weighted Moving Average) variance rather than a fixed rolling standard deviation. This means the script adapts faster to changes in the statistical behavior of the source, without waiting for the full lookback window to shift. In fast-moving or regime-changing markets this produces a more responsive and accurate measure of statistical extension.
How to use it:
Connect any external indicator plot to the Source input. The script will calculate and display:
Smoothed Z-Score as histogram and line, color-coded by zone
Raw Z-Score as a reference behind the smoothed line
Reference lines at ±1σ, ±2σ and ±3σ
Dashboard showing current Z-Score, zone classification, direction and raw Z value
The example chart uses the Fast Line from Bjorgum's TSI indicator as the source input, demonstrating how the Z-Score identifies statistical extremes on a momentum oscillator.
Settings
Source: connect any external indicator plot
Lookback: number of bars for the rolling mean (default 20)
EWMA Half-Life: controls how quickly the volatility measure adapts to recent behavior (default 15)
Z-Score Smoothing: EMA smoothing applied to the raw Z-Score to reduce noise (default 3)
How to read the zones:
Gray: neutral, source near its mean
Light blue / light orange: mild extension beyond ±1σ
Blue / red: statistically extended beyond ±2σ — observe closely
Dark blue / dark red: rare extreme beyond ±3σ
Important note:
This script is an observation tool. It identifies statistical extremes but does not generate buy or sell signals. Always use it as additional context alongside your own analysis. Past statistical extremes do not guarantee future reversals.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.