OPEN-SOURCE SCRIPT
Rolling Z-Score (Quant Lab)

What does this Z-Score measure?
• src (default = close) → the value of the series you selected
• len → the window you are measuring based on the average of the last few bars
• Z ≈ 0 → price close to the average
• Z > 2 → price 2 standard deviations above the average (extremely positive deviation)
• Z < -2 → 2 standard deviations below the average (extremely negative deviation)
In modern mean-reversion strategies:
• Z > +2 → short / take profit candidate
• Z < –2 → long / dip buy candidate
• src (default = close) → the value of the series you selected
• len → the window you are measuring based on the average of the last few bars
• Z ≈ 0 → price close to the average
• Z > 2 → price 2 standard deviations above the average (extremely positive deviation)
• Z < -2 → 2 standard deviations below the average (extremely negative deviation)
In modern mean-reversion strategies:
• Z > +2 → short / take profit candidate
• Z < –2 → long / dip buy candidate
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.