OPEN-SOURCE SCRIPT

STH and LTH NUPL Z-Score | Astral Vision

757
STH and LTH NUPL Z-Score | Astral Vision 🌠💠

Net Unrealized Profit/Loss (NUPL) measures the aggregate unrealized gain or loss held across the entire Bitcoin supply, expressed as a fraction of market capitalization. It quantifies whether the network as a whole is sitting in profit or loss relative to the price at which each coin last moved on-chain.

This indicator standardizes NUPL statistically, offering two distinct time horizons: a short-term window (default 155 days) that captures intra-cycle sentiment extremes, and a long-term window (default 730 days) that identifies macro cycle tops and bottoms. Both produce a Z-Score that measures how far current NUPL deviates from its historical mean in standard deviation units, making every cycle directly comparable regardless of Bitcoin's price level.

A unique Overlay Bands mode back-projects the Z-Score thresholds onto the price chart as dynamic price levels, derived by inverting the NUPL formula through Realized Cap and circulating supply, showing exactly what price corresponds to each statistical extreme in real time.

Calculation ⚙️

`NUPL = (Market Cap − Realized Cap) / Market Cap`

`Z-Score = (NUPL − SMA(NUPL, length)) / StdDev(NUPL, length)`

Applied independently with a short-term length (STH) and a long-term length (LTH). The overlay band prices are back-calculated by inverting NUPL at the threshold levels:

`Band Price = Realized Cap / (1 − NUPL_threshold) / Supply`

Plots 📊
  • Z-Score line in the indicator panel, colored by active regime or trend direction depending on visualization mode
  • Overbought and oversold threshold lines for the active time horizon
  • Zero midline when Trend mode is active
  • Overlay Bands projected on the price chart: overbought price level (negative color) and oversold price level (positive color)
  • Background highlight on the price chart when Z-Score breaches either threshold (Background Color mode)
  • Candle coloring on the price chart by active regime (Plot Candle mode)


Inputs 🎛️
  • `Time Horizon` switches between Short Term NUPL (STH) and Long Term NUPL (LTH) Z-Score
  • `Visualization` selects display mode: Background Color, Plot Candle, Trend, or Overlay Bands
  • `Z-Score Length LTH` : lookback for long-term standardization (default 730)
  • `Z-Score Length STH` : lookback for short-term standardization (default 155)
  • `STH OB / OS Threshold` : Z-Score extremes for the short-term window (default +2.2 / −2.7)
  • `LTH OB / OS Threshold` : Z-Score extremes for the long-term window (default +1.7 / −4.0)


Colors 🎨

5 Astral Vision presets + custom override. Default: Hermes. Positive color activates at oversold extremes and below-zero trend; negative color activates at overbought extremes and above-zero trend.

Purpose 🎯

Standard NUPL indicators plot the raw ratio with fixed absolute thresholds, which lose relevance as Bitcoin's market structure evolves across cycles. A level that defined a top in 2017 carries different statistical weight in 2024.

This indicator solves that by standardizing NUPL dynamically, making thresholds statistically consistent across all cycles. The dual time horizon (STH for tactical entries and exits, LTH for macro positioning) gives traders two independent lenses on the same underlying metric.
The Overlay Bands mode eliminates the need to mentally translate Z-Score levels back to price: the indicator does it directly on the chart, showing the exact price at which NUPL would reach each statistical extreme given the current Realized Cap and supply.

Disclaimer ⭕️

It is not financial advice, not an investment recommendation, and not affiliated with any financial institution, research firm, or organization of any kind. All content is provided for educational and informational purposes only. Always conduct your own research before making any financial decision.

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。