Seconds order flow
Normalize recorded volume and delta on a 10-second chart, with confirmed-bar updates.
Choose 10 seconds in the chart interval menu. The same script works at 1s, 5s, 15s, 30s and 45s. Seconds bars and footprint rows come from recorded trades; a minute candle cannot supply the trades inside its six 10-second bars. Missing intervals stay absent. Check the installation’s historical coverage before comparing sessions or running a strategy.
ta.zscore(source, len) returns the current sample’s distance from the rolling population mean in standard deviations. It includes the current sample, waits for len finite samples, ignores missing samples and returns zero for a constant window. Like other stateful ta.* functions, forming evaluations do not alter confirmed state. Lengths from 1 to 10000 are supported.
script "Seconds order flow"
input length = input.int(60, title: "Window in bars", min: 2, max: 10000)
data chart = subscribe(data.ohlcv)
pane flow = pane(title: "Volume and delta deviations", height: 0.25)
plot (
volume = plot.line(title: "Volume z-score", color: color.blue, on: flow)
delta = plot.histogram(title: "Delta z-score", color: color.orange, on: flow)
)
on chart.close {
volume.plot(ta.zscore(chart.volume, length))
delta.plot(ta.zscore(chart.buyVolume - chart.sellVolume, length))
}A 60-bar window at 10s represents ten minutes of bars when every interval traded. Missing bars make the elapsed time longer. The first 59 samples have no output. Large deviations describe unusual measured activity; they do not establish a trade direction by themselves.