Examples
Sweeps
One aggressive order that trades through several prices at once. With order-by-order data each trade knows which aggressive order it belongs to, so a sweep is marked once, on its last execution.
indicator "Sweeps" { overlay: true }
minLevels = input.int("Min prices traded", 3, min: 2)
minSize = input.int("Min total size", 20, min: 1)
on trade(t) {
if not na(t.levels) and t.sweep_end and t.levels >= minLevels and t.sweep >= minSize {
label.new(t.time, t.price, (t.is_buy ? "▲ " : "▼ ") + str(t.sweep) + " × " + str(t.levels),
color: t.is_buy ? #26a69a : #ef5350, glow: 8)
}
}What to notice:
na(t.levels)is true without order-by-order data (and before the order-by-order window starts): the test makes the script silent there instead of wrong;t.levelscounts the distinct prices traded by the aggressive order;t.sweepis its total size.