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.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。