Flipped Inverted Z-Score (Subpane)Flipped Inverted Z-Score (Subpane) Indicator
What It Does
This indicator measures how far an asset's current price deviates from its long-term average, expressed as a Z-Score — a statistical measure of standard deviations from the mean.
The description "flipped inverted" means the score rises when price is above its long-term average (bullish territory) and falls when price is below it (bearish territory), making it intuitive to read at a glance.
The indicator also highlights when an asset is overheated (orange) and when the asset has cooled off significantly (blue). Oftentimes when an asset is overheated investors are taking profit, and when an asset is oversold investors are accumulating. It's important though to note that an asset can be overbought or oversold for a long period of time (or may in fact never return to prior highs or lows). The z-score highlights bright green and bright red at extreme values, further enhancing these overbought and oversold areas.
The indicator occupies a separate subpane below your main chart, so it never clutters your price action.
Core Calculations
Three values drive everything:
1-Year Moving Average (MA) — the long-term baseline representing "fair value"
Standard Deviation Proxy MA — a shorter MA used to normalize the deviation, making the score comparable across different assets and price ranges
Flipped Z-Score — computed as -(1Y MA - Price) / Std Dev MA, so positive = price above fair value, negative = price below
The Z-Score is dimensionless and asset-agnostic, meaning it works equally well on Bitcoin at $100k or a stock at $15. This normalization is the key benefit over a plain moving average crossover indicator.
Visual Elements
Z-Score Line
The main line changes color dynamically:
🟢 Lime — Strongly above threshold (bullish momentum)
🟩 Green — Mildly positive (above zero, below threshold)
🟥 Maroon — Mildly negative (below zero, above threshold)
🔴 Red — Strongly below threshold (bearish momentum)
Slow & Fast Moving Averages of the Z-Score
Two smoothed MAs are overlaid on the Z-Score line itself, helping filter noise and identify trend direction within the indicator. Both turn green above zero and red below zero.
Background Highlighting (Hot/Cold Zones)
An optional orange or blue background appears when conditions align for potentially overbought or oversold readings:
🟠 Orange background — Z-Score is elevated, above both MAs, and exceeds the hot threshold → potential overbought/overheated zone
🔵 Blue background — Z-Score is depressed, below both MAs, and exceeds the cold threshold → potential oversold/undervalued zone
Crossover Dots (Optional Alerts)
Small colored dots mark moments when the Z-Score crosses above or below the Slow MA — useful as entry/exit signal triggers or for setting TradingView alerts.
Baseline Reference Line
A horizontal line at zero marks the dividing line between price being above or below long-term fair value. (Additional lines can be added to help as references. You may find that certain assets are less volatile, and therefore deviate less from the base reference line. This difference may also occur over time for example in the case of a new asset versus a more mature asset.)
User-Configurable Settings
Setting Default — What It Controls
Price Source (Close) — Which OHLCV value drives the calculation
1-Year MA Period (365 bars) — Long-term "fair value" baseline length
Std Dev Proxy Period (150 bars) — Normalization window, shorter = more sensitive
Z-Score Deviation Threshold (±SD) (0.50) — Where the line color flips from mild to strong
Background Hot Threshold (0.34) — Minimum Z-Score to trigger orange background
Background Cold Threshold (0.40) — Minimum Z-Score depth to trigger blue background
Enable Background Highlighting (On) — Toggle hot/cold background on or off
Show Horizontal Reference Lines (On) — Toggle the zero baseline line
Show Z-Score Moving Averages (On) — Toggle the slow and fast MA lines
Slow MA Period (50 bars) — Smoothing period for the trend-following MA
Fast MA Period (3 bars) — Smoothing period for the responsive MA
Show Crossover Dots (Off) — Toggle the MA crossover signal dots
Practical Use Cases
Macro cycle positioning — on daily/weekly charts with default 365-bar settings, the score gives a birds-eye view of where an asset sits in its broader cycle, useful for sizing positions larger or smaller
Overbought/oversold screening — orange and blue backgrounds highlight historically stretched conditions worth watching for reversals
Trend confirmation — when the Z-Score, Slow MA, and Fast MA are all aligned on the same side of zero, it confirms the broader trend direction
Cross-asset comparison — because the score is normalized, you can apply identical settings to BTC, ETH, SPY, or any stock and compare readings directly
Alert triggers — crossover dots (when enabled) give discrete signal events you can attach TradingView alerts to, removing the need to watch the chart constantly
Tips for Tuning
Shorter timeframes (1H, 4H): consider reducing the 1-Year MA period and Std Dev period proportionally, and uncomment the threshold lines in the source code for finer visual guidance
More sensitive signals: lower the Fast MA period toward 1–2 and tighten the deviation threshold
Reduce noise: raise the Slow MA period and increase the hot/cold thresholds so backgrounds only appear during truly extreme readings
Pine Script®指标






















