Nicolas

Delta Flow: cumulative delta candles, delta divergences and absorption

Studio Only
Category: Indicators By: Nicolas Created: December 2, 2026, 6:04 PM
December 2, 2026, 6:04 PM
Indicators
0 Comments
ProRealCode Script
Delta Flow: cumulative delta candles, delta divergences and absorption

Delta Flow shows the cumulative delta of the day in its own panel under the price, drawn as candles. It rises when buyers lead and falls when sellers do. A signal line follows it, and the gap between the two is shaded. When price makes a new swing high that the cumulative delta does not confirm, or a new swing low, the divergence is drawn in the panel and on the price chart, with an alert. Candles with a lot of volume and very little movement are marked as absorption. A table sums up the day.

This code is written in ProRealCode Script and runs with ProRealCode Studio on ProRealTime Web.

Cumulative delta indicator on a 1-minute Mini DAX chart, with cumulative delta candles, a signal line and delta divergences marked on the price

Mini DAX, 1 minute. The bullish divergence after 15:30 comes before the rally: price made a lower low, the cumulative delta a higher low. The bearish divergence before 12:00 did not stop the rise. A divergence against a strong move fails often, and the capture shows both cases.

What the cumulative delta shows

The delta of a candle is the volume bought minus the volume sold. The cumulative delta, often called CVD for cumulative volume delta, adds up the delta of every candle since the start of the day. Order flow traders read it next to the price: when both rise together, buyers are carrying the move. When price rises and the cumulative delta stays flat or falls, the rise is happening without them, and it is more fragile.

This indicator estimates the buy and sell volume from the candles of the chart, not from the individual trades. Each candle’s volume is split from where it closed in its range: a close on the high counts as all buying, a close on the low as all selling, a close in the middle as half and half. The estimate gets finer as the chart’s timeframe gets smaller.

1. The cumulative delta candles and the signal line

  • The candles: each one opens where the previous one closed and closes at the new cumulative delta. It is green when the candle’s delta is positive and red when it is negative. A long candle is a minute where one side clearly dominated.
  • The signal line: in yellow, the 20-candle average of the cumulative delta (adjustable). It works like the signal line of an oscillator: the cumulative delta above its signal means the buying pressure is growing, below it means it is fading.
  • The shaded gap: green when the cumulative delta is above its signal, red when it is below. The wider the gap, the stronger the push.
  • The daily restart: by default the cumulative delta restarts from zero on the first candle of each day, marked by a tinted column in the panel. The zero line then tells you whether buyers or sellers lead since the start of the day. Turn the switch off to keep one continuous line over the whole history.

2. Delta divergences

The indicator looks for the swing highs and swing lows of the price, with 5 candles on each side by default. Each new swing is compared with the previous one of the same kind:

  • Bearish divergence: price makes a higher high, but the cumulative delta is lower than it was at the previous high. Buyers pushed price up with less net buying than before.
  • Bullish divergence: price makes a lower low, but the cumulative delta is higher than it was at the previous low. Sellers pushed price down with less net selling than before.

Each divergence is drawn twice. In the panel, a line joins the two points of the cumulative delta. On the price chart, a line joins the two swings and a “Delta divergence” label points at the second one, in red for a bearish divergence and in green for a bullish one.

A swing is only known once the candles after it have closed, so a divergence appears 5 candles after the high or the low it marks. It is then final and does not repaint. A shorter swing length gives earlier and more frequent divergences, a longer one gives fewer and more significant ones. With the daily restart on, two swings are only compared inside the same day.

3. Absorption candles

Absorption is a lot of volume for very little movement: one side hits the market hard and the other side takes it all without giving ground. The indicator marks a candle as absorption when its volume is above 2 times its 50-candle average while its range is below 0.7 times the average range. Both thresholds are settings. The colour of the dot says where it happened in the range of the last 20 candles:

  • Teal, under the candle: low in the recent range. Buyers absorbed the selling, which often happens near the end of a decline.
  • Orange, above the candle: high in the recent range. Sellers absorbed the buying.
  • Grey: in the middle of the range, where it says less.

The same dot is drawn on the cumulative delta in the panel, so you can see what the delta was doing at that moment.

The table

  • Cumulative delta: its value, and whether it is above or below its signal line.
  • Last candle delta: the estimated buy minus sell volume of the current candle.
  • Bought today: the share of the day’s volume estimated as buying, on a gauge from 40% to 60%. Around 50%, neither side leads.
  • Divergences: how many were found today, and whether the last one was bullish or bearish.
  • Absorption candles: how many were marked today.

The price can be up on the day while the cumulative delta is negative, as in the capture: the delta counts where every candle closed in its range, not how far price travelled.

Alerts

Each divergence sends an alert when it is confirmed in real time: “Bearish delta divergence” or “Bullish delta divergence”, with the price of the swing. Alerts are not replayed on the history when the code loads.

Settings and how to use it

Paste the code into a new Studio tab and run it on an intraday chart of an instrument with volume: index futures such as the Mini DAX or the Nasdaq, or stocks. The code opens its own panel under the price, and draws the divergences and the absorption dots on the price chart as well. Every setting is a field of the Variables form:

  • Restart the cumulative delta each day: a switch, on by default.
  • Signal line: candles: the length of the average, 20 by default.
  • Divergences: swing length: the number of candles on each side of a swing, 5 by default.
  • Absorption: volume above x times the average: 2 by default. Raise it to keep only the heaviest candles.
  • Absorption: range below x times the average: 0.7 by default. Lower it to keep only the tightest candles.

On an instrument without volume, every candle counts as one unit. The cumulative delta then adds up where the candles close in their range, which still reads the pressure, without the weight of the volume.

A typical reading: price comes down to a support, a teal absorption dot appears under a candle, the next swing low prints a bullish divergence, and the cumulative delta crosses back above its signal line. Each of these is a reason. None of them is a signal on its own.

Under the hood

The code also shows several additions of ProRealCode Script: input() fields with a switch, DRAWCANDLE to draw candles from computed values, COLORBETWEEN and BACKGROUNDCOLOR, PivotHigh and PivotLow for swings that do not repaint, ONPRICE to send a drawing from a panel to the price chart, alert() with the side and the price of the signal, and a table with DRAWTABLE, TABLECELL and TABLEGAUGE.

// ============================================================================
// Delta Flow
// Cumulative delta candles, divergences and absorption, in their own panel
// ----------------------------------------------------------------------------
// Author: Nicolas — ProRealCode
// Runs with ProRealCode Studio: https://www.prorealcode.com/prorealcode-studio/
// ----------------------------------------------------------------------------
// Under the price, the cumulative delta of the day drawn as candles: it rises
// when buyers lead and falls when sellers do, with a signal line and a shaded
// gap between the two. When price makes a new swing high and the cumulative
// delta does not (or the mirror on a low), a divergence is drawn in the panel
// and on the price, with an alert. Candles with a lot of volume and very
// little movement are marked as absorption, on the price and in the panel.
// Buy and sell volume are estimated from where each candle closed in its
// range: the platform gives the candles, not the individual trades.
// ============================================================================

DEFPARAM overlay = false

input(resetDaily, 1, "Restart the cumulative delta each day", bool)
input(signalLen, 20, "Signal line: candles", int)
input(pivotLen, 5, "Divergences: swing length", int)
input(absVol, 2, "Absorption: volume above x times the average", float)
input(absRange, 0.7, "Absorption: range below x times the average", float)

// ── 1. Delta of each candle and cumulative delta ────────────────────────────
IF volume > 0 THEN
vol = volume
ELSE
vol = 1
ENDIF
rng = high - low
IF rng > 0 THEN
buyV = vol * (close - low) / rng
ELSE
buyV = vol / 2
ENDIF
delta = 2 * buyV - vol
newDay = date <> date[1]

once cvdAll = 0
cvdAll = cvdAll + delta
IF barindex = 0 OR (resetDaily AND newDay) THEN
cvdOpen = 0
dayBuy = 0
dayVol = 0
divs = 0
absorbs = 0
ELSE
cvdOpen = cvd[1]
ENDIF
cvd = cvdOpen + delta
dayBuy = dayBuy + buyV
dayVol = dayVol + vol
signal = Average[signalLen](cvd)

// ── 2. The cumulative delta as candles, the gap to its signal line shaded ───
IF cvd >= cvdOpen THEN
DRAWCANDLE(cvdOpen, cvd, cvdOpen, cvd) COLOURED(60, 220, 130) BORDERCOLOR(60, 220, 130)
ELSE
DRAWCANDLE(cvdOpen, cvdOpen, cvd, cvd) COLOURED(240, 80, 90) BORDERCOLOR(240, 80, 90)
ENDIF
IF cvd >= signal THEN
COLORBETWEEN(cvd, signal, 60, 220, 130, 35)
ELSE
COLORBETWEEN(cvd, signal, 240, 80, 90, 35)
ENDIF
IF resetDaily AND newDay THEN
BACKGROUNDCOLOR(120, 140, 200, 40)
ENDIF

// ── 3. Divergences between the swings of price and the cumulative delta ─────
ph = PivotHigh[pivotLen, pivotLen](high)
pl = PivotLow[pivotLen, pivotLen](low)
once hiBar = -1
once loBar = -1
IF ISSET(ph) THEN
pBar = barindex - pivotLen
sameDay = (resetDaily = 0) OR (date[pivotLen] = hiDate)
IF hiBar >= 0 AND sameDay AND ph > hiPrice AND cvdAll[pivotLen] < hiCvd THEN
divs = divs + 1
lastDiv = -1
DRAWSEGMENT(hiBar, hiShown, pBar, cvd[pivotLen]) COLOURED(255, 120, 130) STYLE(line, 2)
DRAWSEGMENT(hiBar, hiPrice, pBar, ph) COLOURED(255, 120, 130) STYLE(line, 2) ONPRICE
DRAWLABEL(pBar, ph, "Delta divergence", arrowdown, small, "Higher high in price, lower high in cumulative delta") COLOURED(255, 255, 255) FILLCOLOR(175, 55, 65) ONPRICE
alert("Delta Flow", "Bearish delta divergence at #ph#", onceperbar, 1, {side: "short", price: ph})
ENDIF
hiBar = pBar
hiPrice = ph
hiCvd = cvdAll[pivotLen]
hiShown = cvd[pivotLen]
hiDate = date[pivotLen]
ENDIF
IF ISSET(pl) THEN
pBar = barindex - pivotLen
sameDay = (resetDaily = 0) OR (date[pivotLen] = loDate)
IF loBar >= 0 AND sameDay AND pl < loPrice AND cvdAll[pivotLen] > loCvd THEN
divs = divs + 1
lastDiv = 1
DRAWSEGMENT(loBar, loShown, pBar, cvd[pivotLen]) COLOURED(90, 235, 160) STYLE(line, 2)
DRAWSEGMENT(loBar, loPrice, pBar, pl) COLOURED(90, 235, 160) STYLE(line, 2) ONPRICE
DRAWLABEL(pBar, pl, "Delta divergence", arrowup, small, "Lower low in price, higher low in cumulative delta") COLOURED(255, 255, 255) FILLCOLOR(40, 150, 95) ONPRICE
alert("Delta Flow", "Bullish delta divergence at #pl#", onceperbar, 1, {side: "long", price: pl})
ENDIF
loBar = pBar
loPrice = pl
loCvd = cvdAll[pivotLen]
loShown = cvd[pivotLen]
loDate = date[pivotLen]
ENDIF

// ── 4. Absorption: a lot of volume, very little movement ────────────────────
// Low in the recent range, buyers absorbed the selling (teal). High in the
// range, sellers absorbed the buying (orange).
avgV = Average[50](vol)
avgRng = Average[50](rng)
hh = Highest[20](high)
ll = Lowest[20](low)
IF avgV > 0 AND vol > absVol * avgV AND rng < absRange * avgRng AND hh > ll THEN
absorbs = absorbs + 1
place = (close - ll) / (hh - ll)
IF place < 0.4 THEN
DRAWPOINT(barindex, low, 4) COLOURED(40, 210, 210, 220) BORDERCOLOR(200, 255, 255) ONPRICE
DRAWPOINT(barindex, cvd, 3) COLOURED(40, 210, 210, 220) BORDERCOLOR(200, 255, 255)
ELSIF place > 0.6 THEN
DRAWPOINT(barindex, high, 4) COLOURED(255, 160, 50, 220) BORDERCOLOR(255, 235, 200) ONPRICE
DRAWPOINT(barindex, cvd, 3) COLOURED(255, 160, 50, 220) BORDERCOLOR(255, 235, 200)
ELSE
DRAWPOINT(barindex, close, 3) COLOURED(170, 180, 205, 200) BORDERCOLOR(230, 235, 245) ONPRICE
DRAWPOINT(barindex, cvd, 2) COLOURED(170, 180, 205, 200) BORDERCOLOR(230, 235, 245)
ENDIF
ENDIF

// ── 5. The table ────────────────────────────────────────────────────────────
IF islastbarupdate THEN
board = DRAWTABLE(6, 2, topleft) FILLCOLOR(14, 18, 30, 235) BORDERCOLOR(50, 60, 90)
TABLEMERGE(board, 0, 0, 1, 2)
TABLECELL(board, 0, 0, "Delta flow", bold, center, 14) COLOURED(220, 228, 245)
cTxt = ROUND(cvd)
TABLECELL(board, 1, 0, "Cumulative delta") COLOURED(150, 165, 195)
IF cvd >= signal THEN
TABLECELL(board, 1, 1, "#cTxt# · above signal", bold, right) COLOURED(60, 220, 130)
ELSE
TABLECELL(board, 1, 1, "#cTxt# · below signal", bold, right) COLOURED(240, 80, 90)
ENDIF
dTxt = ROUND(delta)
TABLECELL(board, 2, 0, "Last candle delta") COLOURED(150, 165, 195)
IF delta >= 0 THEN
TABLECELL(board, 2, 1, "+#dTxt#", right) COLOURED(60, 220, 130)
ELSE
TABLECELL(board, 2, 1, "#dTxt#", right) COLOURED(240, 80, 90)
ENDIF
buyShare = 50
IF dayVol > 0 THEN
buyShare = dayBuy / dayVol * 100
ENDIF
shareTxt = ROUND(buyShare * 10) / 10
TABLECELL(board, 3, 0, "Bought today") COLOURED(150, 165, 195)
TABLEGAUGE(board, 3, 1, buyShare, 40, 60, "#shareTxt#%") GRADIENTCOLOR(buyShare, 45, 55, "#f0505a", "#8fa4c0", "#3cdc82")
TABLECELL(board, 4, 0, "Divergences") COLOURED(150, 165, 195)
IF lastDiv = 1 THEN
TABLECELL(board, 4, 1, "#divs# · last bullish", right) COLOURED(90, 235, 160)
ELSIF lastDiv = -1 THEN
TABLECELL(board, 4, 1, "#divs# · last bearish", right) COLOURED(255, 120, 130)
ELSE
TABLECELL(board, 4, 1, "none yet", right) COLOURED(220, 228, 245)
ENDIF
TABLECELL(board, 5, 0, "Absorption candles") COLOURED(150, 165, 195)
TABLECELL(board, 5, 1, "#absorbs#", right) COLOURED(220, 228, 245)
ENDIF

RETURN signal COLOURED(250, 220, 80) STYLE(line, 1) AS "Signal", 0 COLOURED(120, 130, 155, 120) STYLE(dottedline, 1) AS "Zero"
No ITF file for this code
A Studio Only code is not imported into ProRealTime™. Copy it and paste it into the ProRealCode Studio editor.
Nicolas
Nicolas Legend
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

ProRealCode ProRealCode
Loading...