VPIN Flow Regime [OutOfSampleLab]VPIN Flow Regime visualises order-flow toxicity and buy/sell pressure directly on your chart, with non-repainting flow-price divergence. It describes the current state of the tape. It does not give buy or sell signals.
How it works
- Each bar's volume is split into buy and sell parts using Bulk Volume Classification: the buy fraction is the CDF of the standardised close-to-close change. Two paper-faithful variants are selectable: the standard-normal CDF (Easley, Lopez de Prado & O'Hara, 2012) or the fat-tailed Student-t CDF with 0.25 degrees of freedom (their 2016 paper). To our knowledge no other public script offers both.
- VPIN toxicity = sum |buy - sell| / sum volume over N bars. An unsigned measure of how one-sided flow has been. It is coloured by its own rolling percentile into a regime light: Quiet, Normal, Elevated, Burst.
- Buy pressure = net flow rescaled to 0-100 (50 = balanced).
- Divergence: when price makes a higher high (or lower low) that net flow does not confirm. Confirmed on pivots a few bars later, so it never repaints. By default the divergence lines and labels are drawn directly on the price chart.
Alerts
- Toxicity crossing into Elevated / Burst / back to calm.
- Bullish / bearish flow-price divergence.
All alerts are state-change events, not trade instructions.
Honest limitations (please read)
- This is a bar-based approximation of VPIN, not tick-level VPIN on a true volume clock. Read relative levels and percentiles, not absolute values.
- PulseWire volume is feed-dependent; on many FX/index/CFD symbols it is tick count, not traded volume, and the reading is weak there. Prefer symbols with real volume.
- Aggressor classification is imperfect and depends on the window settings.
This is an impersonal educational tool that runs the same for everyone. Not financial advice, no performance claims.
References: Easley, Lopez de Prado & O'Hara (2012), Review of Financial Studies 25(5); (2016), Journal of Financial Economics 120(2); Lee & Ready (1991), Journal of Finance 46(2). Indicator

Effective Spread OscillatorOverview
Effective Spread Oscillator is a liquidity gauge built from price alone. It estimates the effective bid-ask spread — the real round-trip cost of trading — from open/high/low/close bars, with no quote or order-book data, then percentile-ranks it into a 0–100 read. High = a wide effective spread: thin, illiquid, stressed conditions where slippage and gaps are large. Low = a tight spread: deep, liquid, orderly trade. It is an analytical study of market liquidity and trading friction — not a directional signal and not a strategy.
Why these parts are ONE tool (mashup justification)
Liquidity is normally invisible without Level-2 data. This reconstructs it from bars and then makes it usable, in a chain where each link fixes what the previous one can't do alone:
A low-frequency spread estimator recovers the effective spread from the geometry of OHLC prices — the cost the tape hides. Two are offered: Abdi-Ranaldo (close vs the high-low mid-range) and Corwin-Schultz (consecutive high-low ranges). Negative small-sample estimates — a known statistical artefact of these methods — are floored at zero.
Percentile ranking turns an instrument-specific cost into a universal 0–100 read, so "expensive liquidity" means the same thing on an index future, a stock, or FX. A raw spread number in basis points is not comparable across symbols; a percentile is.
A liquidity-state verdict (stressed / normal / liquid) plus a widening-vs-tightening read makes it legible at a glance, which a bare number isn't.
The calibration harness then tests the well-documented link on your instrument: does a spread spike actually precede a volatility expansion? It reports the conditional hit rate against the unconditional base rate, so you see the Edge rather than assume it.
Chained, they answer one question: is liquidity stressed right now, and has that stress preceded bigger moves here?
How it works
The estimator is computed on log prices and evaluated one bar back (so no future value is referenced), averaged over a window, optionally smoothed, and percentile-ranked over a lookback into the 0–100 oscillator. A spike arms when the spread crosses into the high band; the harness then checks whether the realised range over the next horizon exceeds k × ATR × √horizon more often than the base rate. (The √horizon term keeps the base rate informative near 50% instead of saturating on intraday charts.)
How to use it
The high band (above the upper guide) is stressed / illiquid: widen stops, expect slippage and gaps, and treat breakouts with care — this is where volatility expansions cluster. The low band is liquid / orderly: tighter behaviour, cleaner fills. Use it as a risk and position-sizing context that sits behind your directional tools, and read the Edge row to see whether spread spikes have actually preceded bigger ranges on this symbol. Spikes are marked in the pane and, optionally, on the price chart. The dashboard has a Compact layout (default) and a Pro layout (estimator in use, spread in bps, spike sample, base rate). Context — never a standalone trigger.
Universal across markets
The high / low / close inputs are configurable, so it runs on any instrument and timeframe. Defaults target intraday index futures. Crucially, it needs no volume, so it also works on volume-less feeds (cash indices, spot FX) where flow-based tools cannot.
Non-repainting
The estimator is evaluated one bar back, so it never references a future value, and the calibration harness logs and resolves only on confirmed bars, so its statistics never inflate intrabar. The live oscillator value updates each bar, like any oscillator.
Originality
The spread estimators are published academic work, credited below. What's original here is the construction around them: the percentile normalisation that makes the cost comparable across instruments, the liquidity-state and widening/tightening read, the price-overlay stress marker, and — most of all — the forward-calibration harness that tests the spread-spike → volatility-expansion link against a base rate on your own symbol rather than asserting it. Clean-room implementation; no third-party code reused.
Concept credits
Serial-covariance spread estimator — Richard Roll (1984)
High-low range spread — Shane Corwin & Paul Schultz (2012)
Close-high-low spread — Farshid Abdi & Angelo Ranaldo (2017)
The current state of the art generalising this family to the full OHLC information set is the EDGE estimator of David Ardia, Emanuele Guidotti & Tim Kroencke (Journal of Financial Economics, 2024). This script implements the Corwin-Schultz and Abdi-Ranaldo estimators.
Honest limits
These are estimates of the effective spread from bar geometry, not measured quotes — accurate in aggregate, noisy bar to bar, which is exactly why a window and smoothing are used. Estimates can be small and are floored at zero in tiny samples. The Edge figures are in-sample, with overlapping forward windows and no costs — descriptive context, not a verified backtest. Nothing here predicts direction.
Disclaimer
Research and educational tool only. Not financial advice and no guarantee of profitability or accuracy. Indicators describe past behaviour; they do not predict the future. Trading carries risk of loss. Test out-of-sample and make your own decisions. The author accepts no liability. Indicator
