Footprint Clusters draws a footprint chart on ProRealTime. The candles of the chart are grouped into clusters, each cluster is cut into price rows, and each row shows the volume sold and the volume bought at that price. The cells are coloured by their delta, the busiest row of each cluster is outlined as its point of control, the imbalances between buyers and sellers are marked, and three imbalances in a row leave a zone on the chart. Under each cluster you read its delta and its total volume.
This code is written in ProRealCode Script and runs with ProRealCode Studio on ProRealTime Web.

A candle tells you where price opened, closed and how far it went. A footprint chart opens the candle and shows what happened inside it: how much volume traded at each price, and which side was the more aggressive there. Order flow traders use it to see whether a move is carried by real buying or selling, where one side was absorbed, and at which prices the market agreed the most.
This indicator builds its footprint from the candles of the chart, not from the individual trades. Each candle’s volume is split into a bought part and a sold 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. That volume is then spread over the price rows the candle covered. It is an estimate, and it gets finer as the chart’s timeframe gets smaller: twenty candles of 15 seconds give a more detailed 5-minute footprint than five candles of 1 minute.
A cluster is a group of consecutive candles: 5 by default, so on a 1-minute chart each cluster is a 5-minute footprint. Clusters are aligned on a fixed grid of candles, so they do not shift when a new candle arrives: the last one simply fills up until it is complete. The last 10 clusters are drawn (adjustable).
All clusters share the same price rows. The row height is automatic, sized from the average range of the candles, which gives roughly eight rows for an ordinary cluster. It can also be set by hand in price units.
An imbalance compares the two sides diagonally, as on a classic footprint: the buyers of a row against the sellers of the row below, and the sellers of a row against the buyers of the row above. When one side is at least 3 times the other (the usual 300%, adjustable), the cell is marked with a bright bar: green on its right edge for a buy imbalance, red on its left edge for a sell imbalance. Thin rows are ignored: the heavy side must weigh at least a quarter of the cluster’s busiest row.
Three imbalances of the same side on consecutive rows form a stacked imbalance. The indicator turns it into a zone, drawn with a dotted border and extended to the right. A stacked buy imbalance is a price range where buyers were in control on every row, and it often acts as support when price comes back. A stacked sell imbalance often acts as resistance. A zone stays on the chart until a candle closes through it, and the table counts the zones still open.

5-candle clusters on the Mini DAX, 1 minute. The sell-off after 16:05 leaves a stacked sell imbalance: the red zone stays open above price as a resistance area. A smaller green zone marks a stacked buy imbalance in the last complete cluster.
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. Zoom in until the numbers fit in the cells. Every setting is a field of the Variables form:
On an instrument without volume, every candle counts as one unit of time and the cells show the time spent at each price, with one decimal.
A typical reading: price returns into a stacked buy imbalance zone, the new cluster prints green cells there with a positive delta, and its POC sits at the bottom of the cluster. Each of these is a reason. None of them is a signal on its own.
The code also shows several additions of ProRealCode Script: input() fields with a switch, arrays for the rows of each cluster, nested loops with BREAK, DRAWTEXT with values inserted in the text, dotted rectangles drawn beyond the last candle, and a table with DRAWTABLE, TABLEMERGE and TABLECELL.
// ============================================================================
// Footprint Clusters
// A footprint chart built from the candles of the chart
// ----------------------------------------------------------------------------
// Author: Nicolas — ProRealCode
// Runs with ProRealCode Studio: https://www.prorealcode.com/prorealcode-studio/
// ----------------------------------------------------------------------------
// The chart's candles are grouped into clusters (5 candles of 1 minute make a
// 5-minute footprint). Each cluster is cut into price rows, and each row shows
// the volume sold x the volume bought there, coloured by its delta. The busiest
// row of a cluster is its point of control. A row where one side outweighs the
// other diagonally is an imbalance, and three imbalances in a row leave a zone
// on the chart. Under each cluster: its delta and its volume.
// Buy and sell volume are estimated from where each candle closed in its
// range: the smaller the chart's timeframe, the finer the footprint.
// ============================================================================
input(clusterBars, 5, "Footprint: chart candles per cluster", int)
input(clusters, 10, "Footprint: clusters shown", int)
input(rowSize, 0, "Row height in price (0 = automatic)", float)
input(imbRatio, 3, "Imbalance: one side x times the other", float)
input(stackMin, 3, "Stacked imbalance: rows in a row", int)
input(showNumbers, 1, "Numbers in the cells", bool)
// ── 1. Buy and sell volume of each candle ───────────────────────────────────
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
avgRng = Average[200](high - low)
avgV = Average[50](vol)
IF islastbarupdate THEN
// ── 2. The price rows: the same grid for every cluster ─────────────────────
rowH = rowSize
IF rowH <= 0 THEN
base = avgRng
IF NOT ISSET(base) OR base <= 0 THEN
base = MAX(high - low, ticksize)
ENDIF
rowH = MAX(ticksize, ROUND(base * SQRT(clusterBars) / 6 / ticksize) * ticksize)
ENDIF
// Big volumes are shown in thousands; without volume, one decimal of time
unit = 1
dec = 1
IF avgV * clusterBars > 20000 THEN
unit = 1000
dec = 10
ELSIF avgV <= 1 THEN
dec = 10
ENDIF
lastId = FLOOR(barindex / clusterBars)
stacks = 0
FOR c = 0 TO clusters - 1 DO
cFrom = (lastId - c) * clusterBars
IF cFrom < 0 THEN
BREAK
ENDIF
cEnd = MIN(cFrom + clusterBars - 1, barindex)
// ── 3. The cluster's range, then its volume row by row ───────────────────
cHi = high[barindex - cFrom]
cLo = low[barindex - cFrom]
FOR bi = cFrom TO cEnd DO
k = barindex - bi
cHi = MAX(cHi, high[k])
cLo = MIN(cLo, low[k])
NEXT
r0 = FLOOR(cLo / rowH)
nRows = MIN(60, FLOOR(cHi / rowH) - r0 + 1)
FOR r = 0 TO nRows DO
$fb[r] = 0
$fs[r] = 0
$im[r] = 0
NEXT
cBuy = 0
cSell = 0
FOR bi = cFrom TO cEnd DO
k = barindex - bi
a0 = MAX(0, MIN(nRows - 1, FLOOR(low[k] / rowH) - r0))
a1 = MAX(0, MIN(nRows - 1, FLOOR(high[k] / rowH) - r0))
cnt = a1 - a0 + 1
FOR r = a0 TO a1 DO
$fb[r] = $fb[r] + buyV[k] / cnt
$fs[r] = $fs[r] + sellV[k] / cnt
NEXT
cBuy = cBuy + buyV[k]
cSell = cSell + sellV[k]
NEXT
// The point of control, and the diagonal imbalances: buyers of a row
// against sellers of the row below, sellers against buyers of the row above
cMax = 0
pocR = 0
FOR r = 0 TO nRows - 1 DO
t = $fb[r] + $fs[r]
IF t > cMax THEN
cMax = t
pocR = r
ENDIF
NEXT
// Thin rows are ignored: the heavy side must weigh a quarter of the busiest row
FOR r = 0 TO nRows - 1 DO
IF r > 0 AND $fb[r] >= 0.25 * cMax AND $fb[r] >= imbRatio * $fs[r - 1] THEN
$im[r] = 1
ELSIF r < nRows - 1 AND $fs[r] >= 0.25 * cMax AND $fs[r] >= imbRatio * $fb[r + 1] THEN
$im[r] = -1
ENDIF
NEXT
// ── 4. The cells ─────────────────────────────────────────────────────────
xL = cFrom - 0.45
xR = cFrom + clusterBars - 0.55
xM = cFrom + (clusterBars - 1) / 2
FOR r = 0 TO nRows - 1 DO
b = $fb[r]
s = $fs[r]
t = b + s
IF t > 0 THEN
d = (b - s) / t
m = MIN(1, ABS(d) * 2.5)
IF d >= 0 THEN
cr = 60 - 25 * m
cg = 75 + 120 * m
cb = 100 + 20 * m
ELSE
cr = 60 + 165 * m
cg = 75 - 10 * m
cb = 100 - 15 * m
ENDIF
yLo = (r0 + r) * rowH
yHi = yLo + rowH
a = 70 + 150 * t / cMax
IF r = pocR THEN
DRAWRECTANGLE(xL, yLo, xR, yHi) FILLCOLOR(cr, cg, cb, a) COLOURED(250, 220, 80)
ELSE
DRAWRECTANGLE(xL, yLo, xR, yHi) FILLCOLOR(cr, cg, cb, a) COLOURED(16, 20, 30)
ENDIF
IF $im[r] = 1 THEN
DRAWSEGMENT(xR, yLo, xR, yHi) COLOURED(70, 255, 160) STYLE(line, 3)
ELSIF $im[r] = -1 THEN
DRAWSEGMENT(xL, yLo, xL, yHi) COLOURED(255, 90, 110) STYLE(line, 3)
ENDIF
IF showNumbers THEN
sTxt = ROUND(s / unit * dec) / dec
bTxt = ROUND(b / unit * dec) / dec
DRAWTEXT("#sTxt# x #bTxt#", xM, yLo + rowH / 2, Dialog, Standard, 10) COLOURED(235, 240, 250)
ENDIF
ENDIF
NEXT
// ── 5. Stacked imbalances: a zone, kept while price has not closed through
runSign = 0
runLen = 0
FOR r = 0 TO nRows DO
sg = 0
IF r < nRows THEN
sg = $im[r]
ENDIF
IF sg = runSign AND sg <> 0 THEN
runLen = runLen + 1
ELSE
IF runSign <> 0 AND runLen >= stackMin THEN
zLo = (r0 + r - runLen) * rowH
zHi = (r0 + r) * rowH
broken = 0
FOR bi = cEnd + 1 TO barindex DO
k = barindex - bi
IF (runSign = 1 AND close[k] < zLo) OR (runSign = -1 AND close[k] > zHi) THEN
broken = 1
BREAK
ENDIF
NEXT
IF broken = 0 THEN
stacks = stacks + 1
IF runSign = 1 THEN
DRAWRECTANGLE(xR, zLo, barindex + 3, zHi) FILLCOLOR(70, 255, 160, 26) COLOURED(70, 255, 160, 170) STYLE(dottedline, 1)
ELSE
DRAWRECTANGLE(xR, zLo, barindex + 3, zHi) FILLCOLOR(255, 90, 110, 26) COLOURED(255, 90, 110, 170) STYLE(dottedline, 1)
ENDIF
ENDIF
ENDIF
runSign = sg
runLen = 0
IF sg <> 0 THEN
runLen = 1
ENDIF
ENDIF
NEXT
// ── 6. The cluster's candle on its left edge, its delta and volume below ──
cOpen = open[barindex - cFrom]
cClose = close[barindex - cEnd]
DRAWSEGMENT(xL - 0.25, cLo, xL - 0.25, cHi) COLOURED(150, 160, 180) STYLE(line, 1)
IF cClose >= cOpen THEN
DRAWSEGMENT(xL - 0.25, cOpen, xL - 0.25, cClose) COLOURED(60, 220, 130) STYLE(line, 4)
ELSE
DRAWSEGMENT(xL - 0.25, cOpen, xL - 0.25, cClose) COLOURED(240, 80, 90) STYLE(line, 4)
ENDIF
dTxt = ROUND((cBuy - cSell) / unit * dec) / dec
vTxt = ROUND((cBuy + cSell) / unit * dec) / dec
yBase = r0 * rowH
IF cBuy >= cSell THEN
DRAWTEXT("+#dTxt#", xM, yBase - 0.7 * rowH, Dialog, Bold, 11) COLOURED(60, 220, 130)
ELSE
DRAWTEXT("#dTxt#", xM, yBase - 0.7 * rowH, Dialog, Bold, 11) COLOURED(240, 80, 90)
ENDIF
DRAWTEXT("#vTxt#", xM, yBase - 1.6 * rowH, Dialog, Standard, 10) COLOURED(150, 165, 195)
IF c = 0 THEN
lastDelta = dTxt
lastUp = cBuy >= cSell
lastPoc = (r0 + pocR + 0.5) * rowH
ENDIF
NEXT
// ── 7. The table ───────────────────────────────────────────────────────────
board = DRAWTABLE(6, 2, topleft) FILLCOLOR(14, 18, 30, 235) BORDERCOLOR(50, 60, 90)
TABLEMERGE(board, 0, 0, 1, 2)
TABLECELL(board, 0, 0, "Footprint clusters", bold, center, 14) COLOURED(220, 228, 245)
TABLECELL(board, 1, 0, "Cluster") COLOURED(150, 165, 195)
TABLECELL(board, 1, 1, "#clusterBars# candles", right) COLOURED(220, 228, 245)
TABLECELL(board, 2, 0, "Row height") COLOURED(150, 165, 195)
TABLECELL(board, 2, 1, "#rowH#", right) COLOURED(220, 228, 245)
TABLECELL(board, 3, 0, "Last cluster delta") COLOURED(150, 165, 195)
IF lastUp THEN
TABLECELL(board, 3, 1, "+#lastDelta#", bold, right) COLOURED(60, 220, 130)
ELSE
TABLECELL(board, 3, 1, "#lastDelta#", bold, right) COLOURED(240, 80, 90)
ENDIF
pocTxt = ROUND(lastPoc / ticksize) * ticksize
TABLECELL(board, 4, 0, "Last cluster POC") COLOURED(150, 165, 195)
TABLECELL(board, 4, 1, "#pocTxt#", right) COLOURED(250, 220, 80)
TABLECELL(board, 5, 0, "Stacked imbalances") COLOURED(150, 165, 195)
TABLECELL(board, 5, 1, "#stacks# open", right) COLOURED(220, 228, 245)
IF unit = 1000 THEN
TABLEMERGE(board, 6, 0, 1, 2)
TABLECELL(board, 6, 0, "Volumes in thousands", center) COLOURED(150, 165, 195)
ENDIF
ENDIF
RETURN