Market Structure
Swing High / Swing Low
A local price extreme, a bar whose high (or low) stands above (below) its neighbors on both sides. The atoms from which market structure is built.
A swing high is a bar whose high exceeds the highs of the bars around
it. A swing low is the mirror. The simplest formal definition uses a
symmetric width w:
swing high at bar i ⇔ high(i) > high(i±1 … i±w)
swing low at bar i ⇔ low(i) < low(i±1 … i±w)
(w = 2 gives the classic 5-bar fractal. Larger widths find fewer, more
significant swings.)
The confirmation lag
By definition, a swing needs w bars after the extreme before it can be
confirmed. You never know a swing formed until later. Honest backtests must
respect this; treating a swing as known at its own bar is look-ahead bias,
and one of the subtler ways backtests cheat.
What swings are for
Confirmed swings are the reference points of market structure analysis. Sequences of higher highs and higher lows define trend. Clusters of swings mark support and resistance. The break of a significant swing is a break of structure. And stops naturally live just beyond the swing that justified the trade.
On AlphaProve
williams_fractals in the indicator library is the symmetric-width swing
detector the definition above describes, ready on ctx.indicators without
hand-rolling the neighbor comparison. The confirmation lag is enforced for
you rather than left to discipline: the engine decides on bar close and fills
on the next open, and higher-timeframe series aggregate with no lookahead, so
a swing cannot leak into a decision before the bars that confirm it have
printed.