Volume Heatmap & Bubbles brings an order flow style view to ProRealTime charts. Behind the candles, a heatmap shows where the volume traded and how long each price level stays “hot”. On top, bubbles mark the heavy candles in green or red, depending on whether buyers or sellers dominated. On the right, a buy/sell volume profile sits next to the live best bid and best ask. A table gives the cumulative delta, the busiest price and the balance of the order book at the touch.
This code is written in ProRealCode Script and runs with ProRealCode Studio on ProRealTime Web.

Order flow heatmaps are popular with futures scalpers because they show at a glance which prices matter. The bright horizontal streaks are the levels where a lot of volume changed hands. They often act as support and resistance later, because many positions were opened there. The dark areas are the prices the market went through quickly and may cross again just as fast.
A full order book heatmap needs every level of market depth, tick by tick. A ProBuilder indicator does not get that. It gets the candles and, in ProRealCode Script, the live best bid and best ask. This indicator therefore builds its heatmap from the traded volume of each candle. That is the part of the order flow that actually happened, not the orders that could still be cancelled.
The indicator takes the last 150 bars (adjustable) and cuts their price range into 40 rows. Each candle spreads its volume evenly over the rows its range covers. Every row keeps a memory that fades a little at each new bar: with the default 0.94, a level loses 6% of its heat per bar. A level that keeps trading stays bright, while a level that the market leaves fades back into the dark blue. That is what draws the streaks across the chart.
Each candle’s volume is split into an estimated buy part and sell part 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 difference is the candle’s delta.
The buy/sell split is an estimate from the candle, not a count of trades at the bid and at the ask. It reads the pressure of each candle well, but it is not a true footprint.
To the right of the last bar, a volume profile adds up the whole window row by row, with the buy part in green and the sell part in red. The busiest row is the point of control, extended as a dotted yellow line across the heatmap. The high volume nodes of the profile line up with the bright streaks of the heatmap. The low volume nodes, the short rows, are the gaps that price tends to cross quickly.
On a future or a stock, the indicator reads the live order book at the touch with BID, ASK, BIDSIZE and ASKSIZE. The best bid and best ask are drawn as two short lines after the last candle, with a label giving their price and the size waiting there. The table shows the size imbalance on a gauge, from −100% (only sellers at the touch) to +100% (only buyers). These values refresh about four times a second. They are not stored in the history, because the platform publishes no past order book, so they only appear on the last bar. On an instrument with no book, the table shows “no book”.
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. It works from 15 seconds to 15 minutes. Leave some space on the right of the chart for the profile. Every setting is a field of the Variables form:
A typical reading: price comes back to a bright streak of the heatmap that lines up with a high volume node of the profile, a large bubble appears there against the move, and the cumulative delta turns. Each of these is a reason. None of them is a signal on its own.

Memory set to 1 on 15-second candles: nothing fades, each row gets brighter as volume builds up, and the heatmap becomes a cumulative volume at price map that matches the profile on the right.

1000 bars, 50 rows, memory 0.99 and 100 colour steps on 15-second candles: the high volume nodes of the session stand out as long streaks, with the live bid and ask at the right edge.
The code also shows several additions of ProRealCode Script: input() fields, a FUNCTION returning three values (the r, g, b of the heat ramp), arrays holding the whole grid of the heatmap, two passes over it with run-length merging of the rectangles, DRAWPOINT for the bubbles, drawings beyond the last bar, the live BID, ASK, BIDSIZE and ASKSIZE, and a table with DRAWTABLE, TABLECELL, TABLESPARK and TABLEGAUGE.
// ============================================================================
// Volume Heatmap & Bubbles
// An order-flow style view built from the chart's own candles
// ----------------------------------------------------------------------------
// Author: Nicolas — ProRealCode
// Runs with ProRealCode Studio: https://www.prorealcode.com/prorealcode-studio/
// ----------------------------------------------------------------------------
// Behind the candles, a heatmap of where the volume traded: each candle spreads
// its volume over the prices it covered, and every price level keeps a memory
// that fades bar after bar, so busy levels leave bright streaks across the
// chart. On top: bubbles for the heavy candles (green when buyers dominated,
// red when sellers did), a buy/sell volume profile on the right, the live best
// bid and ask with their sizes, and a table with the cumulative delta.
// Buy and sell volume are estimated from where each candle closed in its
// range: the platform gives the candles, not the individual trades.
// ============================================================================
input(lookback, 150, "Heatmap: bars", int)
input(rows, 40, "Heatmap: rows", int)
input(memory, 0.94, "Heatmap: memory per bar (0.80 short, 0.99 long)", float)
input(steps, 12, "Heatmap: colour steps", int)
input(bubbleMin, 1.8, "Bubbles: volume above x times the average", float)
input(profWidth, 25, "Profile: width (bars)", int)
input(profGap, 4, "Profile: space after the last bar", int)
// The heat ramp: navy for a faint level, then blue, cyan, yellow, and red for
// the busiest. A function can return several values: here r, g, b.
FUNCTION heat(t)
IF t < 0.25 THEN
u = t / 0.25
RETURN 20 + 10 * u, 40 + 60 * u, 110 + 110 * u
ELSIF t < 0.5 THEN
u = (t - 0.25) / 0.25
RETURN 30 + 10 * u, 100 + 120 * u, 220 + 10 * u
ELSIF t < 0.75 THEN
u = (t - 0.5) / 0.25
RETURN 40 + 210 * u, 220 + 10 * u, 230 - 170 * u
ENDIF
u = (t - 0.75) / 0.25
RETURN 250, 230 - 170 * u, 60 - 20 * u
ENDFUNCTION
// ── 1. Buy and sell volume of each candle, and the cumulative delta ─────────
// Without volume (a cash index), every candle weighs 1: the heatmap then shows
// the time spent at each price.
IF volume > 0 THEN
vol = volume
ELSE
vol = 1
ENDIF
IF high > low THEN
buyV = vol * (close - low) / (high - low)
ELSE
buyV = vol / 2
ENDIF
sellV = vol - buyV
delta = buyV - sellV
once cvd = 0
cvd = cvd + delta
avgV = Average[50](vol)
IF islastbarupdate THEN
n = MIN(lookback, barindex + 1)
x0 = barindex - n + 1
// ── 2. The price grid of the window ────────────────────────────────────────
hi = high
lo = low
FOR k = 0 TO n - 1 DO
hi = MAX(hi, high[k])
lo = MIN(lo, low[k])
NEXT
step = (hi - lo) / rows
IF step <= 0 THEN
step = ticksize
ENDIF
// ── 3. First pass: the fading memory of every price level, bar by bar ─────
// $g holds the whole grid, one row after the other for each bar.
FOR b = 0 TO rows - 1 DO
$h[b] = 0
$pb[b] = 0
$ps[b] = 0
NEXT
top = 0
FOR k = n - 1 DOWNTO 0 DO
b0 = MAX(0, MIN(rows - 1, FLOOR((low[k] - lo) / step)))
b1 = MAX(0, MIN(rows - 1, FLOOR((high[k] - lo) / step)))
share = vol[k] / (b1 - b0 + 1)
bshare = buyV[k] / (b1 - b0 + 1)
c = n - 1 - k
FOR b = 0 TO rows - 1 DO
v = $h[b] * memory
IF b >= b0 AND b <= b1 THEN
v = v + share
$pb[b] = $pb[b] + bshare
$ps[b] = $ps[b] + share - bshare
ENDIF
$h[b] = v
$g[c * rows + b] = v
top = MAX(top, v)
NEXT
NEXT
// ── 4. Second pass: paint the grid, one rectangle per run of equal colour ──
// Merging neighbours of the same colour keeps a few hundred rectangles
// instead of thousands.
FOR b = 0 TO rows - 1 DO
$runFrom[b] = x0
$runLvl[b] = 0
NEXT
IF top > 0 THEN
FOR c = 0 TO n DO
FOR b = 0 TO rows - 1 DO
IF c < n THEN
lvl = FLOOR(POW($g[c * rows + b] / top, 0.6) * steps)
ELSE
lvl = -1
ENDIF
IF lvl <> $runLvl[b] THEN
IF $runLvl[b] > 0 THEN
t = MIN(1, $runLvl[b] / steps)
(cr, cg, cb) = heat(t)
DRAWRECTANGLE($runFrom[b] - 0.5, lo + b * step, x0 + c - 0.5, lo + (b + 1) * step) FILLCOLOR(cr, cg, cb, 60 + 130 * t) COLOURED(cr, cg, cb, 0)
ENDIF
$runFrom[b] = x0 + c
$runLvl[b] = lvl
ENDIF
NEXT
NEXT
ENDIF
// ── 5. Bubbles on the heavy candles, sized by their volume ────────────────
bubbles = 0
IF volume > 0 OR avgV > 1 THEN
FOR k = 0 TO n - 1 DO
IF avgV[k] > 0 AND vol[k] > bubbleMin * avgV[k] THEN
sz = MIN(5, 1 + FLOOR((vol[k] / avgV[k] - bubbleMin) * 2))
bubbles = bubbles + 1
IF delta[k] >= 0 THEN
DRAWPOINT(barindex - k, close[k], sz) COLOURED(60, 220, 130, 210) BORDERCOLOR(210, 255, 225, 240)
ELSE
DRAWPOINT(barindex - k, close[k], sz) COLOURED(240, 80, 90, 210) BORDERCOLOR(255, 215, 215, 240)
ENDIF
ENDIF
NEXT
ENDIF
// ── 6. The volume profile of the window: buyers in green, sellers in red ───
pMax = 0
poc = 0
FOR b = 0 TO rows - 1 DO
IF $pb[b] + $ps[b] > pMax THEN
pMax = $pb[b] + $ps[b]
poc = b
ENDIF
NEXT
xp = barindex + profGap
IF pMax > 0 THEN
FOR b = 0 TO rows - 1 DO
lb = $pb[b] / pMax * profWidth
ls = $ps[b] / pMax * profWidth
IF lb + ls > 0 THEN
DRAWRECTANGLE(xp, lo + b * step, xp + lb, lo + (b + 1) * step) FILLCOLOR(60, 200, 120, 170) COLOURED(60, 200, 120, 0)
DRAWRECTANGLE(xp + lb, lo + b * step, xp + lb + ls, lo + (b + 1) * step) FILLCOLOR(230, 80, 90, 170) COLOURED(230, 80, 90, 0)
ENDIF
NEXT
pocPrice = lo + (poc + 0.5) * step
DRAWSEGMENT(x0, pocPrice, xp + profWidth, pocPrice) COLOURED(250, 230, 60, 200) STYLE(dottedline, 1)
ENDIF
// ── 7. The live best bid and best ask, with the size waiting at each ───────
hasBook = ISSET(bid) AND ISSET(ask)
IF hasBook THEN
DRAWSEGMENT(barindex, ask, xp - 1, ask) COLOURED(240, 80, 90) STYLE(line, 2)
DRAWSEGMENT(barindex, bid, xp - 1, bid) COLOURED(60, 220, 130) STYLE(line, 2)
DRAWLABEL(xp + profWidth + 1, ask, "Ask #ask# · #asksize#", none, small, left) COLOURED(255, 255, 255) FILLCOLOR(175, 55, 65)
DRAWLABEL(xp + profWidth + 1, bid, "Bid #bid# · #bidsize#", none, small, left) COLOURED(255, 255, 255) FILLCOLOR(40, 150, 95)
ENDIF
// ── 8. The table ───────────────────────────────────────────────────────────
board = DRAWTABLE(6, 2, topleft) FILLCOLOR(12, 18, 36, 235) BORDERCOLOR(40, 70, 140)
TABLEMERGE(board, 0, 0, 1, 2)
TABLECELL(board, 0, 0, "Volume heatmap", bold, center, 14) COLOURED(214, 228, 255)
TABLECELL(board, 1, 0, "Cumulative delta") COLOURED(150, 170, 210)
TABLESPARK(board, 1, 1, cvd, 60) COLOURED(80, 200, 230)
dTxt = ROUND(delta)
TABLECELL(board, 2, 0, "Last candle delta") COLOURED(150, 170, 210)
IF delta >= 0 THEN
TABLECELL(board, 2, 1, "+#dTxt#", bold, right) COLOURED(60, 220, 130)
ELSE
TABLECELL(board, 2, 1, "#dTxt#", bold, right) COLOURED(240, 80, 90)
ENDIF
pocTxt = ROUND(pocPrice / ticksize) * ticksize
TABLECELL(board, 3, 0, "Busiest price") COLOURED(150, 170, 210)
TABLECELL(board, 3, 1, "#pocTxt#", right) COLOURED(250, 230, 60)
TABLECELL(board, 4, 0, "Heavy candles") COLOURED(150, 170, 210)
TABLECELL(board, 4, 1, "#bubbles# of #n#", right) COLOURED(214, 228, 255)
TABLECELL(board, 5, 0, "Book at the touch") COLOURED(150, 170, 210)
IF hasBook AND bidsize + asksize > 0 THEN
imb = ROUND((bidsize - asksize) / (bidsize + asksize) * 100)
TABLEGAUGE(board, 5, 1, imb, 0 - 100, 100, "#imb#%") GRADIENTCOLOR(imb, 0 - 60, 60, "#f0505a", "#8fa4c0", "#3cdc82")
ELSE
TABLECELL(board, 5, 1, "no book", right) COLOURED(150, 170, 210)
ENDIF
ENDIF
RETURN