OPEN-SOURCE SCRIPT

Liquidity Divergence Oscillator

374
Overview

Liquidity Divergence Oscillator is a distribution / absorption detector. It estimates liquidity health from Kyle's lambda — the price impact per unit of signed volume — and reads it for divergence against price. When price grinds to a higher high while liquidity health makes a lower high, large participants are often unloading size into strength (a distribution footprint); the mirror — price lower low, health higher low — is absorption. A forward-calibration harness scores whether those price/liquidity divergences have actually followed through on your instrument. It is a flow-structure read, not a signal to trade alone.

Why it is different — not another CVD/volume oscillator

CVD, the A/D line and MFI all measure the direction and amount of flow — who is buying or selling. Kyle's lambda measures something orthogonal: how much price moves per unit of that flow — the depth and fragility of the book. Price pushing to new highs while lambda quietly rises (liquidity thinning) is the classic footprint of size being distributed into strength, and no direction-only flow tool sees it. That impact axis is what makes a liquidity divergence its own, independent read — and it's why this belongs alongside your CVD tools rather than duplicating them. It's also distinct from a liquidity map: this is a standalone divergence oscillator, built to surface the turn, not to chart the shelves.

How the parts work as one tool


Signed volume — sv = volume × sign(price change), a tick-rule aggressor proxy.
Kyle's lambda — Cov(ΔP, sv) / Var(sv) over a rolling window: the regression slope of price change on signed flow, the standard lambda estimator. High = thin/stressed book, low = deep/liquid.
Liquidity health — −z(lambda), smoothed and tanh-squashed to a soft ±100 pane so "liquid vs stressed" reads on a fixed, self-scaling axis (0 = balance, ±50 ≈ a 1.6σ stretch).
Divergence — regular and hidden, from confirmed price pivots against health at those pivots.
Calibration harness — each regular divergence is queued and resolved a fixed horizon later against the unconditional base rate, reporting Hit / Edge / sample and a Wilson-gated star. A divergence class that never beats the base rate here is adding no information — and the dashboard shows that instead of assuming it.


How to use it

Read the oscillator's side and slope — above 0 is liquidity firming, below 0 is liquidity stressed. Treat a divergence mark as context (a distribution or absorption warning), never a standalone entry. Before you weight it, check the dashboard: if the Bull/Bear Edge isn't clearly positive with an adequate sample and a star, that class isn't carrying an edge on this instrument. Signals are marked in the pane and, optionally, on the price chart. Combine with your own levels, trend and risk rules — it describes behaviour; it decides nothing.

Universal & non-repainting

High/Low/Price are inputs, so the divergence engine runs on any series; the lambda estimate needs real volume, so use the futures (a cash index reads "no volume"). Pivots confirm a fixed number of bars after the fact and don't move once printed, and the calibration harness logs and resolves only on confirmed bars, so its statistics never repaint intrabar. The live oscillator updates each bar like any oscillator. Edge figures are in-sample, forward-measured at a fixed horizon, with no costs — a study aid, not a backtest.

Originality

Kyle's lambda and price/oscillator divergence are public; the Wilson interval is Edwin B. Wilson's. What's original is the specific construction: the detrend → z-score → tanh-squash liquidity-health oscillator built off the lambda estimate, the combined regular+hidden divergence engine keyed to it, and the forward-calibration harness that scores each divergence class against its base rate. Clean-room implementation; no third-party Pine code reused.

Concept credits


Price impact / lambda — Albert S. Kyle (1985)
Tick-rule aggressor signing — after the classic trade-sign literature (Lee & Ready)
Wilson score confidence interval — Edwin B. Wilson
Price/oscillator divergence — standard public technical-analysis technique


Disclaimer

Educational / informational only. Not financial advice, not a signal, not a recommendation. The lambda estimate uses tick-rule signed volume — a proxy, not the true tape — so liquidity health is an inference, not an order-book reading. Edge figures are in-sample, forward-measured with no costs. Past behaviour does not assure future behaviour. Markets carry risk. Do your own research and paper-trade before risking capital; you alone are responsible for your decisions.

Pernyataan Penyangkalan

Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.