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. Подробнее читайте в Условиях использования.