OPEN-SOURCE SCRIPT

Kurdistani Style Cycle

1 621
Kurdistani Style Cycle

A composite on-chain indicator that identifies Bitcoin market cycle phases
using a weighted Z-score of MVRV, NUPL, and a SOPR proxy. It maps market
conditions into five distinct phases and overlays normalized BTC price.

═══════════════════════════════════════════════════
KEY ON‑CHAIN METRICS USED
═══════════════════════════════════════════════════

1. MVRV (Market Value to Realized Value)
MVRV = Market Cap / Realized Cap
- High values: large unrealized profit, possible market tops.
- Low values: large unrealized loss, possible market bottoms.

2. NUPL (Net Unrealized Profit/Loss)
NUPL = 1 – (1 / MVRV) (derived from MVRV to ensure consistency)
- Strongly positive (e.g., >0.75): euphoria / overheated.
- Negative: fear, potential bottoming zone.

3. SOPR Proxy
Since real SOPR requires UTXO data unavailable on TradingView, a proxy
is built from price position relative to short-term and long-term
highest/lowest bands:

Short-term position (STH):
STH_pos = (Price – STH_low) / (STH_high – STH_low) (range 0–1)
Long-term position (LTH):
LTH_pos = (Price – LTH_low) / (LTH_high – LTH_low) (range 0–1)

Raw SOPR Proxy = STH_pos – LTH_pos
Smoothed SOPR Proxy = 5-period SMA of Raw SOPR Proxy

═══════════════════════════════════════════════════
HOW THE COMPOSITE INDEX IS BUILT
═══════════════════════════════════════════════════

Step 1 – Z-Score Normalization
For each component (MVRV, NUPL, SOPR Proxy) a Z-score is calculated
with a common lookback period L (default 365):
Z = (Value – SMA(Value, L)) / StdDev(Value, L)

Step 2 – Weighted Combination (PnL Index)
User-defined weights w1, w2, w3 (default 0.4, 0.4, 0.2).
If the fraction of non‑null components meets or exceeds the
'Min Valid Weight Fraction' threshold, the PnL Index is:

PnL Index = (w1 * MVRV_Z + w2 * NUPL_Z + w3 * SOPR_Z) / (w1 + w2 + w3)

Step 3 – Bull‑Bear Indicator
The final oscillator removes the long-term trend using a simple moving
average (default length 365):

Bull‑Bear = PnL Index – SMA(PnL Index, 365)

Positive values indicate a bullish regime relative to the long-term average,
negative values indicate a bearish regime.

═══════════════════════════════════════════════════
PHASES – THRESHOLDS & INTERPRETATION
═══════════════════════════════════════════════════

The Bull‑Bear value is classified into five phases using two thresholds:
Overheated Threshold (default +1.5)
Early Bull Upper Limit (default +0.5)
Extreme Bear Threshold (default -1.5)

Phase Condition Interpretation
─────────────────────────────────────────────────────────────────────────
Extreme Bear Bull‑Bear ≤ -1.5 Possible deep bottom, extreme fear
Bear -1.5 < Bull‑Bear ≤ 0 Downtrend / consolidation
Early Bull 0 < Bull‑Bear ≤ 0.5 First signs of recovery
Bull 0.5 < Bull‑Bear ≤ 1.5 Healthy uptrend
Overheated Bull Bull‑Bear > 1.5 Euphoria, high risk of correction

Colors on the histogram:
Extreme Bear → solid blue
Bear → cyan / teal
Early Bull → green
Bull → orange
Overheated Bull → red
No data → transparent gray

Small markers:
A green dot above Early Bull columns
A red dot below Overheated Bull columns

═══════════════════════════════════════════════════
WHAT YOU SEE ON THE CHART
═══════════════════════════════════════════════════

• Gray line: the Bull‑Bear oscillator value.
• Colored columns: histogram displaying the current phase.
• Green horizontal line at zero (neutral boundary).
• Red dotted line at the Overheated Threshold (+1.5).
• Blue dotted line at the Extreme Bear Threshold (-1.5).
• Light gray/white line (optional): Z‑score of log(BTC price)
over the same lookback period, showing how far current price
deviates from its long‑term log mean.
• Information table (top‑right): shows live readings for Phase,
Bull‑Bear value, MVRV, NUPL, SOPR Proxy, BTC price, normalized
price Z‑score, and the composite PnL Index (Z).
• A star (*) next to a metric name and an orange warning dot
indicates stale (non‑updating) data, typically on intraday
timeframes where on‑chain data is not refreshed in real time.

A label on the last bar displays the current phase name.

═══════════════════════════════════════════════════
INPUT SETTINGS (fully adjustable)
═══════════════════════════════════════════════════

- MA Length for Cycle (default 365): moving average length
used to extract the cycle from the PnL Index. Shorter
values increase responsiveness but add noise.
- Z‑Score Lookback (default 365): lookback for mean and
standard deviation when normalizing MVRV, NUPL, and SOPR.
- Overheated Bull Threshold (Z) (default 1.5): Z‑score level
that triggers the Overheated phase.
- Early Bull Upper Limit (Z) (default 0.5): upper bound of
the Early Bull phase; crossing above enters the Bull phase.
- Extreme Bear Threshold (Z) (default -1.5): lower bound for
the Extreme Bear phase.
- STH Lookback (default 155): period for short‑term high/low
in the SOPR proxy calculation.
- LTH Lookback (default 365): period for long‑term high/low
in the SOPR proxy calculation.
- MVRV Weight (default 0.4)
- NUPL Weight (default 0.4)
- SOPR Weight (default 0.2)
- Min Valid Weight Fraction (default 0.5): minimum fraction
of total weight that must have valid (non‑null) data for the
composite index to be calculated. Prevents unreliable signals
when one or more components are missing.
- Show Normalized BTC Price Overlay (true/false)
- Price Symbol (default BINANCE:BTCUSDT)
- Price Normalization Lookback (default 365)

═══════════════════════════════════════════════════
DATA SOURCES & STALENESS
═══════════════════════════════════════════════════

• BTC_MARKETCAP (Market Cap) and BTC_MARKETCAPREAL (Realized
Cap) are fetched via request.security from TradingView’s
internal symbols.
• Price is fetched from the user‑selected symbol (default
BINANCE:BTCUSDT).
• On intraday timeframes (less than 1D), on‑chain data often
does not update on every bar. In those cases a star (*)
appears next to the metric and an orange dot is plotted.
Daily or higher timeframes are recommended for the cleanest
signals.

═══════════════════════════════════════════════════
PRACTICAL USAGE GUIDE
═══════════════════════════════════════════════════

- Accumulation / long‑term entries: Extreme Bear (blue columns)
often marks excellent long‑term buying zones.
- Confirmed trend change: Entering Early Bull (green columns)
after a bear phase provides a higher‑probability entry once
momentum turns positive.
- Holding during uptrend: Bull phase (orange) represents a
healthy market. Consider moving stop‑losses higher but
avoid premature exits.
- Taking profits / reducing exposure: Overheated Bull (red
columns) signals that the market is statistically stretched.
A phased exit or partial sell strategy is prudent.
- The normalized price overlay provides a second opinion: when
both the Bull‑Bear indicator and price Z‑score reach
simultaneous extremes, the signal is stronger.

═══════════════════════════════════════════════════
LIMITATIONS
═══════════════════════════════════════════════════

• The SOPR component is a proxy and not real SOPR data.
• On lower timeframes, stale data may cause slight lag.
• In long sideways markets the oscillator may whipsaw
between Bear and Early Bull. Always combine with other
technical or fundamental analysis.
• This indicator is not financial advice. Past performance
does not guarantee future results.

═══════════════════════════════════════════════════
HOW TO INSTALL
═══════════════════════════════════════════════════

Add the indicator to your chart from TradingView’s “Indicators”
panel. It will appear in a separate pane below the price chart.
Adjust the settings via the gear icon to fit your own cycle
analysis framework.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.