OPEN-SOURCE SCRIPT
Rolling Z Score Reversion Map [Pineify]

Rolling Z Score Reversion Map [Pineify]
Overview
This map keeps rolling price Z-score visible while separating reversion-eligible extremes from trend-aligned extremes. It describes context; it does not forecast returns or issue trades.
Problem Definition
Z-score measures distance from a rolling mean in deviation units. Fixed lines such as +2 and -2 treat every extreme alike. That fails when the mean moves: positive Z can persist with a rising mean, so a contrarian reading confuses extension with disequilibrium. The script preserves raw Z and asks separately whether aligned trend and range pressure should withhold a reversion watch.
Design Rationale
Raw Z remains unchanged so its units stay interpretable. Mean slope is expressed as ATR per bar for cross-market comparison. ATR uses a prior-only percentile to avoid fixed price units and candidate self-ranking. Sign alignment isolates positive deviation with rising mean and its negative mirror. High ATR rank adds pressure but cannot dominate alone. A finite closed-bar watch preserves event order; permanent extreme marks would duplicate events. Lag and confirmation delay are accepted for auditable states.
Key Features
How It Works
The script computes a rolling mean and deviation of closes. Raw Z is their price difference divided by deviation; a near-zero denominator returns no value.
ATR defines range scale. Its percentile is a midrank against N prior ATR values: lower samples vote one and ties half. Current ATR is excluded. Mean change over the slope span is divided by ATR and bar count to obtain ATR per bar.
The gate tests whether Z and slope share a sign. Pressure combines 65% aligned trend strength, 20% upper-half ATR expansion, and 15% trend-volatility interaction, bounded from zero to one. An extreme qualifies when absolute Z reaches its rail and pressure stays below the gate.
A newly qualified close freezes watch side and entry Z. The watch ends on a crossing of the evolving mean, expiry, invalid data, or an invalidation-rail extreme with excessive pressure. A crossing is only observed, not caused. Warm-up covers all windows and rank history. Live colors can change; watches, markers, and alerts update on confirmed bars.
How Multiple Indicators Work Together
The components form one filter. Z supplies distance but not reference motion. ATR-normalized slope supplies motion; sign alignment relates it to the deviation. Prior ATR rank adds portable range context. Together they decide whether an extreme starts a watch. Without slope, the fixed-threshold failure returns; without ATR, calm and expansion are alike; without the watch, event chronology disappears.
Trading Ideas and Insights
Use the map to organize observation, not assume reversal. Cyan means pressure is below the gate and an extreme can start a confirmed watch. Orange means the same raw distance has stronger continuation context, so a contrarian label is withheld. A gold zero-axis marker records a later mean crossing. Compare states to find where fixed Z thresholds misdescribe context.
Unique Aspects
The contribution is separating measurement from interpretation. Many filters rescale an oscillator, preventing comparison with ordinary Z rails. Here raw distance stays intact while a bounded, direction-sensitive, range-relative gate classifies events. The watch preserves sequence: qualification occurs first; later bars cross the evolving mean or invalidate. No result is moved backward and no probability is implied.
How to Use
After warm-up, read height as raw Z and color as context. Cyan marks a candidate or active watch, orange a higher-pressure extreme, and gray a balanced or unavailable state. Diamonds and alerts mark confirmed entry. A zero circle records a watched crossing; an orange cross records invalidation. Use 15-minute to weekly charts and Once Per Bar Close alerts. These are states, not trade instructions.
Customization
Z window sets reference horizon; Extreme threshold sets event distance. ATR window and rank length set range context and history needs. Slope span smooths motion; Full trend pressure maps ATR-per-bar slope to full strength. Lower Maximum pressure tightens qualification. Invalidation Z and Maximum watch bars bound observation life. Visual layers can be disabled independently while raw Z and rails remain. Colors support varied themes.
Assumptions and Limitations
Rolling statistics change as samples enter and leave; Z implies neither normality nor stationarity. ATR rank is empirical, not probability, and needs complete history. Weights are design choices, not optimized constants. Slope lags; gaps can outrun it. The watch targets an evolving mean, not the entry mean. Live visuals are provisional, and confirmed events still depend on feed history. Inputs, adjustments, and synthetic charts can change results. Execution, costs, sizing, news, structure, and future returns are outside scope. Pineify checks syntax, not market behavior.
Conclusion
The map adds auditable context without changing Z-score units. Distance remains distance; trend, volatility, and watch state change only its label. Keep lag, sensitivity, and scope explicit.
Overview
This map keeps rolling price Z-score visible while separating reversion-eligible extremes from trend-aligned extremes. It describes context; it does not forecast returns or issue trades.
Problem Definition
Z-score measures distance from a rolling mean in deviation units. Fixed lines such as +2 and -2 treat every extreme alike. That fails when the mean moves: positive Z can persist with a rising mean, so a contrarian reading confuses extension with disequilibrium. The script preserves raw Z and asks separately whether aligned trend and range pressure should withhold a reversion watch.
Design Rationale
Raw Z remains unchanged so its units stay interpretable. Mean slope is expressed as ATR per bar for cross-market comparison. ATR uses a prior-only percentile to avoid fixed price units and candidate self-ranking. Sign alignment isolates positive deviation with rising mean and its negative mirror. High ATR rank adds pressure but cannot dominate alone. A finite closed-bar watch preserves event order; permanent extreme marks would duplicate events. Lag and confirmation delay are accepted for auditable states.
Key Features
- Raw Z-score with symmetric rails.
- ATR-normalized slope, prior-only ATR rank, and direction gate.
- Confirmed watch with mean, pressure, data, and time exits.
- Optional visuals, table, and two alerts.
How It Works
The script computes a rolling mean and deviation of closes. Raw Z is their price difference divided by deviation; a near-zero denominator returns no value.
ATR defines range scale. Its percentile is a midrank against N prior ATR values: lower samples vote one and ties half. Current ATR is excluded. Mean change over the slope span is divided by ATR and bar count to obtain ATR per bar.
The gate tests whether Z and slope share a sign. Pressure combines 65% aligned trend strength, 20% upper-half ATR expansion, and 15% trend-volatility interaction, bounded from zero to one. An extreme qualifies when absolute Z reaches its rail and pressure stays below the gate.
A newly qualified close freezes watch side and entry Z. The watch ends on a crossing of the evolving mean, expiry, invalid data, or an invalidation-rail extreme with excessive pressure. A crossing is only observed, not caused. Warm-up covers all windows and rank history. Live colors can change; watches, markers, and alerts update on confirmed bars.
How Multiple Indicators Work Together
The components form one filter. Z supplies distance but not reference motion. ATR-normalized slope supplies motion; sign alignment relates it to the deviation. Prior ATR rank adds portable range context. Together they decide whether an extreme starts a watch. Without slope, the fixed-threshold failure returns; without ATR, calm and expansion are alike; without the watch, event chronology disappears.
Trading Ideas and Insights
Use the map to organize observation, not assume reversal. Cyan means pressure is below the gate and an extreme can start a confirmed watch. Orange means the same raw distance has stronger continuation context, so a contrarian label is withheld. A gold zero-axis marker records a later mean crossing. Compare states to find where fixed Z thresholds misdescribe context.
Unique Aspects
The contribution is separating measurement from interpretation. Many filters rescale an oscillator, preventing comparison with ordinary Z rails. Here raw distance stays intact while a bounded, direction-sensitive, range-relative gate classifies events. The watch preserves sequence: qualification occurs first; later bars cross the evolving mean or invalidate. No result is moved backward and no probability is implied.
How to Use
After warm-up, read height as raw Z and color as context. Cyan marks a candidate or active watch, orange a higher-pressure extreme, and gray a balanced or unavailable state. Diamonds and alerts mark confirmed entry. A zero circle records a watched crossing; an orange cross records invalidation. Use 15-minute to weekly charts and Once Per Bar Close alerts. These are states, not trade instructions.
Customization
Z window sets reference horizon; Extreme threshold sets event distance. ATR window and rank length set range context and history needs. Slope span smooths motion; Full trend pressure maps ATR-per-bar slope to full strength. Lower Maximum pressure tightens qualification. Invalidation Z and Maximum watch bars bound observation life. Visual layers can be disabled independently while raw Z and rails remain. Colors support varied themes.
Assumptions and Limitations
Rolling statistics change as samples enter and leave; Z implies neither normality nor stationarity. ATR rank is empirical, not probability, and needs complete history. Weights are design choices, not optimized constants. Slope lags; gaps can outrun it. The watch targets an evolving mean, not the entry mean. Live visuals are provisional, and confirmed events still depend on feed history. Inputs, adjustments, and synthetic charts can change results. Execution, costs, sizing, news, structure, and future returns are outside scope. Pineify checks syntax, not market behavior.
Conclusion
The map adds auditable context without changing Z-score units. Distance remains distance; trend, volatility, and watch state change only its label. Keep lag, sensitivity, and scope explicit.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
🚀🚀🚀 Pineify - pineify.app
Essential Toolkit for Every Trader
- AI Pine Script Generator
- Finance AI Agent
- AI Stock Picker
- Pine Script Visual Editor
- Invited indicators
- Strategy Optimizer
- Trading Journal
- Backtest Report
Essential Toolkit for Every Trader
- AI Pine Script Generator
- Finance AI Agent
- AI Stock Picker
- Pine Script Visual Editor
- Invited indicators
- Strategy Optimizer
- Trading Journal
- Backtest Report
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
🚀🚀🚀 Pineify - pineify.app
Essential Toolkit for Every Trader
- AI Pine Script Generator
- Finance AI Agent
- AI Stock Picker
- Pine Script Visual Editor
- Invited indicators
- Strategy Optimizer
- Trading Journal
- Backtest Report
Essential Toolkit for Every Trader
- AI Pine Script Generator
- Finance AI Agent
- AI Stock Picker
- Pine Script Visual Editor
- Invited indicators
- Strategy Optimizer
- Trading Journal
- Backtest Report
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。