Swings¶
Structure · Pivots
Detect swing highs and swing lows using a fractal window of N bars.
Swings is the foundation of market-structure analysis: it finds the swing highs and swing lows — the pivot points where price turned — and marks them on the chart. Every higher-level structure concept (trends, breaks of structure, supply/demand zones, liquidity) is built on top of these pivots. Before you can say "price made a higher high," something has to define what counts as a high. This block is that something.
How it works¶
It uses a fractal definition over the Lookback N window (default 5). A swing high is a bar whose high is greater than the highs of the N bars on each side of it; a swing low is the mirror image with lows. With a lookback of 5, a pivot is only confirmed once 5 bars have printed to its right — which means every swing carries a confirmation lag of N bars and there is no lookahead: the dot appears N bars after the actual turn. The output is a stream of swing points (drawn as dots on the price pane) that downstream structure blocks consume.
When to use it¶
Use Swings whenever you need the raw skeleton of price structure — as a visual reference for marking highs and lows, as the input that defines higher-highs/lower-lows for a trend read, or as the basis for placing stops beyond the last swing. The Lookback N is the key dial: a small N (2–3) catches every minor wiggle (noisy, lots of pivots), while a large N (8–15) keeps only the major structural turns (clean, but later confirmation). Match it to the structure you actually trade.
Example¶
Structure-based stops: wire bars into Swings to identify the most recent swing low, and place your Structural Stop-Loss just beyond it so your risk sits below genuine structure rather than an arbitrary distance. Combine the swing context with an entry trigger into a Buy Signal and backtest in the Tester.
Tips & gotchas¶
- N bars of confirmation = N bars of lag. That's the honest price of a confirmed pivot — and why backtests on it don't cheat.
- Lookback sets the scale. Small N = minor swings (noisy); large N = major swings (clean, later).
- It's a building block. Market Structure, Supply/Demand Zones, and Liquidity Sweep all build on these pivots — keep the lookback consistent across them.
- Major structure lives on higher timeframes — read swings there for the trend that matters.
Related blocks¶
Inputs¶
| Socket | Type | What to wire in |
|---|---|---|
| Bars | bars |
Price bars |
Outputs¶
| Output | Type | Plots as | Description |
|---|---|---|---|
| Swings | swings |
Swing dots | Detected swing highs and lows |
Parameters¶
| Parameter | Type | Default | What it does |
|---|---|---|---|
| Lookback N | number · 2–30 | 5 |
Bars of confirmation on each side of a pivot |
Reference auto-generated from the block catalog · category Structure.