Volatility
Bollinger squeeze and ATR expansion.
Each recipe below is a complete core-logic body: drop it under your market/timeframe pragmas and adjust the thresholds to taste. Every query on this page has been parsed and evaluated against the current XQL grammar.
Bollinger Band Width / Squeeze
The band spread relative to the midline, expressed as a parenthesized arithmetic expression so it can be compared as a single ratio:
(bb_upper(20, 2) - bb_lower(20, 2)) / bb_mid(20, 2) < 0.04Matches when the bands have narrowed to under 4% of the midline: a classic squeeze setup that often precedes a volatility expansion.
ATR Expanding
Squeeze recipes look for volatility contracting; this one looks for the opposite already underway. atr has no source argument (see Functions), so bind it to a let and compare against its own value further back: the same offset-comparison shape as the MACD histogram recipe:
let a = atr(14)
a > a[-10]Matches when the 14-period ATR is higher than it was 10 bars ago: true range is expanding, often accompanying (or preceding) a directional move.