Differences between adjacent list items
deltas x deltas[x]
Where x is a numeric or temporal vector, returns differences between consecutive pairs of its items.
q)deltas 1 4 9 16
1 3 5 7
In a query to get price movements:
update diff:deltas price by sym from trade
With signum to count the number of up/down/same ticks:
q)select count i by signum deltas price from trade
price| x
-----| ----
-1 | 247
0 | 3
1 | 252