OPEN-SOURCE SCRIPT
Rolling Z-Score

A simple statistical indicator that measures how far the current price is from its recent average, expressed in standard deviations (a "z-score"). It helps visualize when price is unusually stretched relative to its own recent behavior.
What it does
This indicator calculates a rolling z-score of price over a user-defined lookback window. The z-score expresses the current value as the number of standard deviations away from its rolling mean:
z = (price − rolling mean) / rolling standard deviation
A reading of 0 means price is exactly at its recent average. +2 means two standard deviations above average; −2 means two below. Values reset continuously as the rolling window moves.
How to read it
Near 0 → price is close to its recent mean
Above +2 → price is statistically stretched to the upside
Below −2 → price is statistically stretched to the downside
The dashed lines mark the ±2 reference levels; the center line marks the mean.
Inputs
Window length: the lookback period for the mean and standard deviation (default 20)
Source: the price series used (default close)
Important notes
A high or low z-score is not a buy or sell signal on its own. In a trending market, price can stay stretched (high or low z-score) for extended periods — an extreme reading can keep getting more extreme. This tool measures statistical deviation; it does not predict reversals. Use it as one input within a broader, tested framework, not as a standalone signal.
What it does
This indicator calculates a rolling z-score of price over a user-defined lookback window. The z-score expresses the current value as the number of standard deviations away from its rolling mean:
z = (price − rolling mean) / rolling standard deviation
A reading of 0 means price is exactly at its recent average. +2 means two standard deviations above average; −2 means two below. Values reset continuously as the rolling window moves.
How to read it
Near 0 → price is close to its recent mean
Above +2 → price is statistically stretched to the upside
Below −2 → price is statistically stretched to the downside
The dashed lines mark the ±2 reference levels; the center line marks the mean.
Inputs
Window length: the lookback period for the mean and standard deviation (default 20)
Source: the price series used (default close)
Important notes
A high or low z-score is not a buy or sell signal on its own. In a trending market, price can stay stretched (high or low z-score) for extended periods — an extreme reading can keep getting more extreme. This tool measures statistical deviation; it does not predict reversals. Use it as one input within a broader, tested framework, not as a standalone signal.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。