OPEN-SOURCE SCRIPT
Telah dikemas kini

Price Volatility Divergence with Reliability Scoring

645
Price–Volatility Divergence with Reliability Scoring

Normally, rising price comes with falling implied volatility — fear drains out of a rally. When price pushes to a new high while fear is also rising (or falls to a new low while fear falls), that disagreement is an anomaly worth flagging. This script builds a "fear" oscillator from an implied-volatility index, marks where it diverges from price, and — the original part — scores in real time whether those divergences have actually been worth trading on your symbol, and which direction is carrying the edge.

Why these components are combined (and how they work together). Three pieces form one pipeline, not three separate signals:

An implied-volatility "fear" series — chosen as raw level, term-slope (vol minus its own trend), or variance-risk-premium (implied minus realized). It's z-scored and negated so price-up/fear-up reads as an ordinary bearish divergence on the line.

Confirmed-pivot divergence between that fear series and price — regular and hidden, with an optional triple-pivot mode.

A binomial-proportion confidence test that asks, for each divergence class, whether the expected move followed more often than a same-zone baseline.

Part 2 only fires where price and fear disagree; part 3 decides whether that disagreement has historically mattered here, per direction. Remove any one and the script can't answer its question — "is this fear divergence worth trading, and which way?"
How to read it. The verdict panel translates the statistics: green = these divergences have beaten a same-spot baseline here; red = they've lost to it (skip, or try another fear measure/timeframe); amber = not established yet; grey = still gathering data. "Best signal" names the direction with the strongest measured edge so you know which side to favour. "Reward : risk" is the average best vs worst move after a signal, in ATR. Optional key-info and per-class tables (off by default) show the full breakdown.

Important — this is a proxy, not literal skew. True option skew needs the full per-strike implied-volatility surface, which charts don't expose. This uses a charted VIX / term-structure proxy, stated plainly so you know exactly what you're reading.
Universal. Needs a price source (the chart) and an implied-volatility index, both set in inputs. Defaults target NIFTY futures with India VIX; change the volatility symbol to VIX, VSTOXX, etc. for other markets.

Outputs for other scripts. Generic EXP_* values (oscillator, signal, probability, edge, edge lower-bound, sample count, regime, implied-vol level, fear percentile) are published to the Data Window for use via input.source().

Concept credits. Implied-volatility index construction — CBOE methodology. Variance-risk-premium — academic options literature. Binomial score confidence interval — E. B. Wilson. Trend-efficiency regime measure — P. Kaufman.

Disclaimer. For research and education only. Not financial advice, not a recommendation, not a guarantee of future results. All figures are in-sample and past-only. Markets carry risk — do your own research and manage your own risk.
Nota Keluaran
v2.1 — An upgraded reliability harness plus robust normalization and a lag-minimal smoother. The implied-volatility fear series, its three measures (Level / Term slope / VRP) and the confirmed-pivot divergence detection are unchanged — set Z-score mode = "Classic (mean/stdev)" and Output smoother = "EMA" for the original normalization.

1. HARNESS+ reliability scoring. The per-class track record now reports a uniqueness-weighted effective sample size, an in-sample / out-of-sample split (the OOS edge is the one to trust — exported as EXP_EdgeOOS, shown on a new "Out-of-sample" panel row), and a multiple-testing deflated significance bar across the four divergence classes.

2. Robust MAD normalization + UltimateSmoother (default on). The fear series z-scored with a median/MAD statistic so volatility spikes don't distort the σ bands, and smoothed with Ehlers' lag-minimal UltimateSmoother. Reversible via "Z-score mode" / "Output smoother".

3. 3-window extreme consensus (opt-in, default off). z as the MEDIAN of the z at half, one and double the window — extreme only when short/medium/long agree.

What is unchanged. The implied-volatility index source, the Level / Term-slope / VRP fear measures, the fear-percentile gate, the confirmed-pivot 2-/3-pivot regular + hidden divergence detection and the zone-conditional baseline are the published logic. Only the scoring harness is upgraded and the normalization made robust; the divergence signals themselves fire exactly as before.

Still context, not a standalone trigger. Needs a volatility index (default India VIX); this is a transparent VIX / term-structure proxy, not literal option skew. Non-repaint: fixed-lag pivots; the harness resolves on confirmed bars; the vol request uses lookahead off. Concept credits unchanged (CBOE IV methodology; variance-risk-premium literature; Wilson; Kaufman; López de Prado uniqueness / OOS / deflation; Ehlers UltimateSmoother).
Nota Keluaran
v2.2 — R1 honest-stats standardization. The reliability scoring is now backed by the published calibration libraries instead of local copies: robust-z via ml_robuststats/2, and the Wilson confidence half-width + hit-rate via ml_calib/2. Every one of those is byte-identical to the formula the script already used, so the fear oscillator (variance-risk-premium / implied-variance / term-slope / level), all four divergence classes and the entire HARNESS+ track record (uniqueness weighting, in-sample/out-of-sample split, deflated significance) are unchanged. A new optional time-of-day significance gate (group 05, default OFF) can restrict divergences to statistically live intraday slots via ml_session/2. Imports are pinned to the exact published v2 versions. Same calibration engine now shared across the whole divergence family.

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.