Anchored Volume Delta with Adaptive Bands MT4
- Indicators
-
Narayanan Mohanan Mohanan Krishnan
MT5/MQL5 developer building Expert Advisors, custom indicators, and backtesting and validation tools. I focus on clean, well-documented, no-repaint code: closed-bar logic, validated buffers, proper handle and memory management. This is the engineering that separates a reliable tool from a fragile - Version: 1.0
This indicator plots Cumulative Volume Delta (CVD) — the running total of each bar's volume, signed by the direction the bar closed — inside adaptive standard-deviation bands. It answers a question price alone does not: is the move being carried by participation, or is it drifting?
The cumulative total restarts at an anchor you choose — daily, weekly or monthly — so the reading is always relative to the current session, week or month rather than to the beginning of chart history. That single control is what makes the same indicator useful on a one-minute forex chart and on a daily index chart, and it is what separates this from a plain cumulative volume line that only ever grows from wherever your history happens to start.
How it works
Each bar contributes its volume to a running total: added when the bar closes above the previous close, subtracted when it closes below, and left unchanged when the close is flat.
A 20-period basis and its standard deviation are then calculated over that cumulative series, and the upper and lower bands are placed at a chosen multiple of the deviation. Because the bands are built from the series' own variability, they widen when participation becomes volatile and contract when it settles — no fixed thresholds to re-tune per instrument.
When the cumulative total reaches an anchor boundary it resets to zero and begins again. On the chart this appears as a clean restart in the line, and the bands re-form around the new period.
What the bands show
A move outside the bands means volume flow has become statistically unusual for that instrument's recent behaviour. A return inside means it has normalised. Neither is a signal to act — they are a description of where participation currently sits relative to its own recent range.
Three readings traders commonly take from this display:
Band contact. The CVD line reaching the upper band marks buying flow stretched relative to its recent range; the lower band marks the same for selling flow. In the screenshots these points are marked in red at the upper band and green at the lower band. What follows a stretched reading is not fixed — flow can normalise, or it can keep extending while the bands widen around it.
Confirmation. Price makes a new high or low and the CVD line makes one too. Participation is travelling with price.
Divergence. Price makes a new low while the CVD line makes a higher low, or the reverse at a high. Price has moved but the volume flow behind it has not followed. This is context, not a prediction — divergences resolve in both directions, and they can persist far longer than expected.
Inputs
- Applied volume — Tick volume (default)
- Anchor period — Continuous, Daily (default), Weekly or Monthly
- Bands period — 20
- Bands deviation — 2.0
An anchor must be coarser than the chart period to mean anything: a daily anchor on a daily chart would reset on every bar. When that happens the indicator falls back to a continuous series, states the reason in the Experts log, and shows the anchor actually in use in its short name — so what you see labelled is always what is running.
Buffers
- Buffer 0 — CVD line
- Buffer 1 — Upper band
- Buffer 2 — Basis
- Buffer 3 — Lower band
All four are readable from an Expert Advisor or another indicator with iCustom(). MQL4 buffers are series-indexed, so shift 1 is the last fully closed bar — read that for values that will not change:
double cvd = iCustom(NULL, 0, "NaaMo\\CVDBands", 0, 1); double upper = iCustom(NULL, 0, "NaaMo\\CVDBands", 1, 1); double basis = iCustom(NULL, 0, "NaaMo\\CVDBands", 2, 1); double lower = iCustom(NULL, 0, "NaaMo\\CVDBands", 3, 1);
The buffer indices match the MetaTrader 5 version exactly. Code written against buffer 2 receives the basis on either platform.
The indicator is self-contained: it calls no other indicator, so nothing else has to be present for it to work.
Across instruments
The screenshots show the indicator on five instruments and several anchor settings. Where marks appear, red marks contact with the upper band and green marks contact with the lower band.
- EURUSD H1, monthly anchor — a longer accumulation than the daily default, with band contact marked at both extremes.
- Dollar index M15, daily anchor — the Data Window open, showing all four buffers named against a single bar.
- US30 Daily — the anchor fallback in action. A daily anchor would reset every bar, so the indicator switched to a continuous series and says Continuous in its label.
- XAUUSD M5, daily anchor — an intraday session where selling flow carries the line through the lower band and stays there while price works lower.
- GBPUSD M1, daily anchor — the shortest timeframe, where the anchor resets are frequent and the bands re-form quickly.
- BTCUSD M15 — the inputs dialog, showing every setting.
Calculation behaviour
Values are calculated only from completed data. Once a bar closes its value is final and does not change. Only the currently forming bar updates as new ticks arrive, and it settles at that bar's close. The indicator uses no look-ahead data and does not repaint closed bars.
The cumulative series is rebuilt deterministically, so the same chart and settings always produce the same values regardless of when the indicator was attached or how the history was loaded.
Notes
- Separate indicator window, 4 lines, 4 buffers.
- Around 20 bars of history are required before the bands begin to draw.
- Tick volume is a proxy for traded volume. Real volume is not available in MetaTrader 4; selecting it stops the indicator with a message rather than substituting something else silently.
- No external dependencies. The cumulative series, the basis and the standard-deviation bands are all calculated inside the indicator. It is a single file that does not call any other indicator, so there is nothing to install alongside it and no dependency on the state of your indicators folder.
- A MetaTrader 5 version is also published, with matching buffer indices.
This indicator is a tool for technical analysis and market-condition filtering. It is not a trading system, it does not generate trading signals, it does not provide investment advice, and it does not open or manage trades automatically. No performance claims are made for it.
Free to download and use. If you find it useful, a rating helps other traders find it.
| More tools from this developer I build MetaTrader indicators and Expert Advisors with an emphasis on clean, documented, no-repaint code — closed-bar logic, validated buffers, and no dependencies on other indicators. Questions about the calculation, the buffers, or using this in your own EA? Send me a private message — I am happy to answer. |
Developed and maintained by Narayanan Mohanan, MetaTrader Developer.
