Examples
Unusual prints
Every trade is compared with the sizes of the trades of the last 30 minutes. Trades in the top percentile are labeled, and the bar's signed volume of such trades is shown in a statistics row.
indicator "Unusual prints" { overlay: true }
minRank = input.float("Min size rank", 99.5, min: 50, max: 100, step: 0.1)
normWin = input.duration("Compare with the last", 30m)
state signed = 0
on trade(t) {
// computed for every trade, so the population is all trades
rk = norm.rank(t.size, normWin, min_count: 500)
if rk >= minRank {
label.new(t.time, t.price, str(t.size), color: t.is_buy ? #26a69a : #ef5350, pulse: 3s)
signed += t.delta
}
}
stat("Unusual", signed, format: "+0", color: signed >= 0 ? #26a69a : #ef5350)
signed = 0What to notice:
- the threshold is a rank, not a size: the same setting works on any instrument and at any hour;
signedis astatevariable filled by the handler, read and reset by the body at the end of each bar.