Large prints
Stream size-filtered trades, bubble them on the chart, and fold them into a per-bar whale delta.
This example combines individual trades with chart bars. It marks large trades and tracks their net buy and sell volume within each bar.

script "Large Prints"
data chart = subscribe(data.ohlcv)
data tape = subscribe(data.trades, minSize: 20.0)
input bubbleScale = input.float(1.0, title: "Bubble Scale", min: 0.2, max: 5.0)
pane flowPane = pane(title: "Whale Delta", height: 0.25)
plot whaleDelta = plot.histogram(title: "Whale Delta", on: flowPane)
state (
// Sized to cover the prints expected in one chart window; past 2000 filtered
// prints the slot counter wraps and the oldest bubble is overwritten.
bubbles = entities.markerPool(max: 2000)
slot: int = 0
barDelta: float = 0.0
)
// Each delivered trade already passed the minSize filter. Draw it where it
// printed and fold it into the per-bar large-print delta.
on tape.trade(tr) {
slot = slot >= 1999 ? 0 : slot + 1
bubbles.get("print", slot).set(
x: tr.time,
y: tr.price,
shape: shape.circle,
color: color.withAlpha(tr.isBuy ? color.up : color.down, 140),
size: math.min(5.0 + tr.size * 0.12 * bubbleScale, 24.0),
)
barDelta = barDelta + (tr.isBuy ? tr.size : -tr.size)
}
on chart.update {
whaleDelta.plot(barDelta, color: barDelta >= 0.0 ? color.up : color.down)
}
on chart.close {
barDelta = 0.0
}Filter at the subscription, not in the handler
minSize: 20.0 drops small prints before they ever reach the script, so the handler only runs for trades that matter. Raising the floor is a subscription change, not a code change.
Trades are events, bars are summaries
The trade handler fires once per print with tr.time, tr.price, tr.size, and tr.isBuy; the chart handlers still run on bar cadence. State is what connects them: barDelta accumulates across trade events and resets when the bar closes.
Limit marker history and size
The pool keeps markers for up to 2,000 qualifying trades. After that, the slot counter wraps and each new marker replaces the oldest one. Bubble sizes are capped so a very large trade does not cover the chart.