Volatility clusters. Quiet periods are followed by expansions, and the switch is often sudden. The scanner measures compression by comparing two volatility envelopes around the same 20-bar average:
| Envelope | Measures |
|---|---|
| Bollinger Bands (2 σ) | Standard deviation of closes |
| Keltner Channel (1.5 × ATR) | Average true range |
When the Bollinger Bands fit inside the Keltner Channel, price is unusually calm for its normal range: a squeeze.
| Element | Meaning |
|---|---|
| Red dot | Squeeze on: volatility compressed |
| Green dot | Squeeze released |
| Bright green bar | Upward momentum, increasing |
| Pale green bar | Upward momentum, fading |
| Bright red bar | Downward momentum, increasing |
| Pale red bar | Downward momentum, fading |
The momentum value is the close minus the average of the Donchian midline and the SMA. It tells you which way the release is going.
Gold's large moves of the last decade — the 2019 breakout and the 2024 rally — both started from long compression phases. In the author's research, long-only H4 squeeze breakouts on XAUUSD with a D1 uptrend filter and stops of 3 ATR or wider had the best profit factor of all engines tested. Tighter stops (2.5 ATR) broke the edge, because squeeze breakouts often retest the breakout level first.
| Input | Default | Description |
|---|---|---|
| Length | 20 | BB, KC and momentum length |
| Bollinger multiplier | 2.0 | Standard deviations |
| Keltner ATR multiplier | 1.5 | ATR multiple |
| Alert when squeeze fires | false | Alert on the first closed bar after a squeeze |
int h=iCustom(_Symbol,PERIOD_H4,"SqueezeScanner",20,2.0,1.5,false); double dot[]; if(CopyBuffer(h,3,1,6,dot)==6) // colour index of the last 6 closed bars { bool recent_squeeze=false; for(int i=0;i<6;i++) if(dot[i]==0) recent_squeeze=true; // 0 = squeeze on }
| Buffer | Content |
|---|---|
| 0 / 1 | Momentum / colour index (0,1 up · 2,3 down) |
| 2 / 3 | Dot / colour index (0 squeeze · 1 released) |
| 5 | Squeeze flag (calculation buffer) |
Author: Shipra Gupta (SGupta30) · squeeze-based Expert Advisors for gold and Bitcoin are in the author's Market profile.
Gold Donchian Breakout Channel (non-repainting, with HTF trend filter)
Donchian channel of the N bars before each bar, midline and confirmed breakout arrows that never repaint. Optional D1 EMA-slope filter shows only breakouts in the higher-timeframe trend. Alerts and push. Any symbol.
Broker Tick and Rollover Spread Forensic Auditor
Read-only forensic script that audits historical broker Bid/Ask ticks in 15-day RAM-safe chunks: computes session spread percentiles (P50/P95), 23:00-00:15 rollover widening ratios, weekday feed blackout gaps, and exports clean millisecond CSV files.
Risk Lot Panel — drag the stop line, read the lot size for your risk percentage
On-chart position-size calculator. Drag the stop line (and optional target line) and the panel shows lots for your risk %, money at risk and reward:risk. Uses OrderCalcProfit, so it is correct for gold, indices, crypto, FX and any account currency.
Gold Trend Breakout Lite — educational XAUUSD trend-following EA
Open-source gold EA built on XAUUSD's multi-day trend persistence: H1 Donchian breakout in the direction of the D1 EMA slope, 3×ATR hard stop, break-even at +1R. Fixed lot, one position, no grid, no martingale.