OPEN-SOURCE SCRIPT
已更新

Volume Flow Divergence Oscillator

632
Volume Flow Divergence Oscillator (VFDO)

Volume Flow Divergence Oscillator

A bounded order-flow oscillator that measures whether buying or selling pressure dominates and how stretched it is, then detects price/flow divergences with statistical filtering. Three interchangeable flow engines share one axis so the same read can be cross-checked three independent ways.

Why these components are combined (and why this is not a generic mashup)

Order-flow pressure can be measured several ways, and each has blind spots. The problem this script solves is specific: raw Cumulative Volume Delta (CVD) trends without bound, so classic "swing-high vs swing-high" divergence on it is unreliable — the comparison ends up dominated by the accumulated drift instead of local buying/selling conviction. Stacking more momentum tools (a second RSI, a MACD) would only double-count the same information.

Instead, this tool (a) detrends and standardizes the flow into a bounded, mean-reverting oscillator so divergence becomes valid, and (b) offers three orthogonal lenses on one question — is buying or selling winning, and is it stretched?:


Normalized CVD — cumulative signed volume, detrended (minus its EMA) and divided by the residual's standard deviation. The reading is a z-score of how stretched flow is versus its own recent trend.
CVD-RSI — Wilder's RSI applied to the detrended CVD (not raw CVD, which would pin near 0/100 in a sustained trend). A 0–100 momentum-of-flow read.
MFI (Money Flow Index) — a volume-weighted RSI that does not depend on the signed-volume estimate, so it acts as a genuine independent cross-check.


These three are not redundant: they are different constructions of the same idea. A divergence that appears on all three is far more robust than one that appears on only one — and if they disagree, the "divergence" is construction-dependent noise. That cross-checking is the core purpose of putting them on a shared bounded axis.

Four context modules sit on top, each adding what the raw line cannot:


Filtered divergence — regular and hidden divergence between price pivots and the flow oscillator, gated by a minimum magnitude (marginal wiggles don't count), a maximum bar-distance between pivots (no stale comparisons), and an optional extreme-zone requirement (only count divergences forming from overbought/oversold, where they carry the most meaning). Lines are drawn on the oscillator curve; price marks print at the confirmation bar.
Gradient extreme zones — ±4σ (or 90/10) bands that shade lighter at the edge and darker as flow pushes further out, marking genuinely stretched conditions.
In-band reversal dots — a red/green dot when the oscillator makes a local turn inside an extreme band, flagging that stretched flow is unwinding.
Adaptive dashboard — a compact panel (oscillator value, zone, last divergence, last reversal, data source) that auto-themes to the chart background for legibility on any color scheme.


How signed volume is estimated (honesty)

True aggressor-tagged delta is unavailable on most TradingView feeds, so signed volume here is estimated: per bar it is summed from lower-timeframe sub-bars (each sub-bar's volume signed by whether it closed up or down), falling back to an intrabar OHLC proxy when sub-bar data isn't available. The dashboard's Delta source row shows which is live ("LTF" vs "proxy"). This is the standard approach CVD tools use; it is an estimate, not exchange-tagged order flow.

How to use


Add to any symbol that reports volume. Read it like a bounded flow gauge: above the upper band = buying stretched; below the lower band = selling stretched; midline = balance.
Treat divergences as context, not standalone triggers. A bearish divergence at the upper extreme means buying conviction is fading as price makes a new high.
Cross-check with the Engine selector: confirm a divergence by switching between Normalized CVD, CVD-RSI and MFI. Agreement across all three is the strong case.
Reversal dots mark stretched-flow unwinding — combine with your own price structure and risk rules.


Settings overview


Data Source — lower-timeframe for the delta estimate; selectable High/Low sources for divergence, so the engine fits any instrument.
Flow Oscillator — engine selector, detrend/normalize window, OB/OS, smoothing, RSI/MFI lengths.
Extreme Zones & Reversals — ±4σ band level, band display, reversal dots.
Divergence — magnitude, pivot length, max bar-distance, extreme-zone gate, regular/hidden.
Dashboard & Theme — colors, position, and Auto/Dark/Light theme.


Defaults are tuned for NSE NIFTY futures on intraday timeframes (1-minute sub-bar delta). For other assets or timeframes, adjust the lower timeframe, normalize window, and band levels — every parameter is exposed.

Originality

This is not a re-skin of a single public indicator. The original contributions are: the detrend-then-standardize normalization that makes CVD divergence valid; three interchangeable flow engines on one shared bounded axis for cross-checking; and a divergence engine with magnitude + distance + extreme-zone gating drawn on the oscillator curve, with in-band reversal detection.

Concept credits


Relative Strength Index — J. Welles Wilder Jr.
Money Flow Index — Gene Quong & Avrum Soudack.
Cumulative Volume Delta and divergence analysis are standard public order-flow / technical-analysis concepts.


This script is an original implementation built around those public concepts and is not affiliated with, nor endorsed by, their originators.

Disclaimer

For research and educational purposes only. Not financial advice and no guarantee of profitability or accuracy. Signed volume is estimated, not exchange-tagged. Indicators describe past price behavior; they do not predict the future. Trading carries risk of loss. Test on out-of-sample data and make your own decisions. The author accepts no liability for any use of this script.

版本注释
What's new in this update

Forward calibration restored — the headline. Every divergence and reversal class (Reg Bull/Bear, Hidden Bull/Bear, Rev +/−) is now resolved by a triple-barrier outcome (profit / stop / horizon), uniqueness-weighted and recency-decayed, and reported as an edge over a zone-matched base rate — for a bearish-from-overbought divergence the benchmark is "how often does price fall after simply being overbought?", so the edge is the value beyond the extreme — with a Wilson interval and a multiple-testing-corrected significance star. You can once again see which divergences actually pay on your instrument.

Better signed volume. Lower-timeframe sub-bars are now signed by where each closed within its own range (not a flat up/down close), and the fallback estimate is a standardized-return (Bulk-Volume) classifier instead of a single OHLC proxy.

Multi-engine agreement. All three engines (Normalized CVD / CVD-RSI / MFI) are computed every bar and an agreement meter reports how many concur on the current side — a built-in cross-check.

Configurable volume source. A volume-source input plus a borrow symbol let the oscillator run on instruments that report no native volume; the volume-weighted index is computed manually so it honours that source.

Identity strip (the TradingView fix). A theme-adaptive strip now shows script name · symbol · timeframe on the chart, resolving the review objection.

Exports bus. The script previously emitted nothing; it now exports 11 generic Data-Window series — EXP_Osc, EXP_OscZ, EXP_Zone, EXP_FlowBias, EXP_Agreement, EXP_RegDiv, EXP_HidDiv, EXP_Reversal, EXP_DeltaSrc, EXP_BullEdge, EXP_BearEdge — for cross-script use.

Packaging. Settings reorganized into 7 numbered groups; all toggles default-on; author names moved into a concept-credits block (universal terms only in the UI); NIFTY/intraday defaults retained; dashboard adaptive to chart background with a key-readouts block plus the per-class calibration table (Pro mode).

Research and educational purposes only — not financial advice. Signed volume is estimated; calibration is in-sample, forward-measured at fixed barriers. Validate out-of-sample before relying on the edge numbers.
版本注释
v1.1 — Four additive layers: robust normalization, a lag-minimal smoother, a walk-forward out-of-sample reliability read, and named VSA bar events. The signed-volume engine, the three flow lenses, the divergence detection and the triple-barrier forward calibration are all unchanged (set CVD normalization = "Classic (÷ stdev)" and Smoother = "EMA" to reproduce the original read).

1. Robust CVD normalization (default on) The "Normalized CVD" engine standardized the detrended CVD residual with residual / stdev — where a single volume-spike bar inflates σ and flattens the whole oscillator. This adds the option to standardize with a median / MAD z-score (median absolute deviation × 1.4826) instead, which shrugs off that one outlier bar so the read stays honest through spikes. Selectable via "CVD normalization"; set it to "Classic (÷ stdev)" for the original.

2. UltimateSmoother option (default on) When oscillator smoothing is on, the smoother can now be Ehlers' UltimateSmoother — lag-minimal, so the line turns sooner than an EMA of the same length without adding noise. Selectable via "Smoother"; set it to "EMA" for the original.

3. Walk-forward out-of-sample reliability The forward-calibration table already reports each divergence class's hit-rate and edge over a zone-matched base — but that's an in-sample read, and in-sample edges flatter. This adds a genuine walk-forward split: the first N resolved signals TRAIN, and every signal after that is scored out-of-sample. The honest OOS edge (out-of-sample hit − zone-matched base, in percentage points) is shown on a new "OOS edge (walk-fwd)" dashboard row. That row is the number to trust.

4. VSA bar events (optional) Adds the current bar's dominant Wyckoff / effort-vs-result event — Upthrust, Shakeout, Stopping Volume — as dedicated alerts, so a divergence printing into an Upthrust or a Stopping-Volume bar can be read together. An optional time-of-day volume baseline judges "heavy volume" against the same clock slot on prior sessions, so a normal-for-the-open bar isn't mistaken for a climax. Off by default; alerts only (no on-pane clutter).

What is unchanged. The lower-timeframe sub-bar signed-volume estimate with its Bulk-Volume fallback, the three flow engines (Normalized CVD, CVD-RSI, volume-weighted MFI) and the agreement meter, the magnitude/distance/extreme-zone-gated divergence detection, the reversal engine, and the entire triple-barrier forward calibration (uniqueness-weighting, recency decay, Wilson interval, Šidák multiple-testing correction, zone-matched base rate) are all byte-for-byte the published version. The new layers only read the existing series; none feeds back into the divergence or calibration logic, and no new plot is drawn.

Still describes past behaviour, not a prediction. Signed volume is estimated, not exchange-tagged. Calibration is forward-measured at fixed barriers with no costs / slippage / stops — read the OOS row, not the in-sample edge. Non-repaint: LTF delta uses confirmed sub-bars; marks print at the confirmation bar; every statistic resolves on confirmed bars. Concept credits unchanged (Wilder RSI; Quong-Soudack money-flow; Easley-López de Prado-O'Hara BVC; López de Prado triple-barrier / uniqueness; Wilson interval; Šidák correction; VSA is the standard Wyckoff vocabulary; Ehlers UltimateSmoother).
版本注释
v1.2 — R1 honest-stats standardization. Robust-z and the Wilson confidence half-width now come from the published calibration libraries (ml_robuststats/2, ml_calib/2), byte-identical to the prior local helpers — the multi-engine flow oscillator, the divergence detection, the marks and every calibration number are unchanged. Shared calibration engine across the divergence family.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。