Swing pivots

The last confirmed swing highs and lows, known only once price has turned away from them.

Causal swing pivots (Phase 3 K1). A high (low) is confirmed when a later close is reversal below (above) it, reversal = max(swing_min_pct % × close, swing_k × ATR before the candle), frozen when each leg starts. Pivots alternate high/low and appear on the confirming candle, never before. bars_since_* count from the pivot's own candle.

Swing pivots is a structure detector: it marks price structure on the chart and counts against the plan's detector limit.

Settings

SettingDefaultRangeWhat it does
atr_period141 to 500ATR length (Wilder) for every buffer.
swing_k20.1 to 20Swing reversal in ATRs: a pivot is confirmed when a close moves this far back.
swing_min_pct0.10 to 10Smallest swing reversal, % of the close.
pivots102 to 50Confirmed pivots kept for the chart.

What it gives

OutputWhat it is
Last swing highPrice of the last confirmed swing high.
Last swing lowPrice of the last confirmed swing low.
Previous swing highThe swing high before the last one.
Previous swing lowThe swing low before the last one.
Swing high confirmedTrue on the candle a swing high is confirmed.
Swing low confirmedTrue on the candle a swing low is confirmed.
Candles since the swing highCandles since the last swing high's own candle.
Candles since the swing lowCandles since the last swing low's own candle.

What it reads

It reads the whole candle (open, high, low, close and volume).

Warm-up

With its default settings, Swing pivots needs 341 closed candles before its first value. A backtest loads them before its start date, so the first trade can already use it.

Test it

Copy this sentence into the Algonney chat to backtest it:

Backtest a strategy on BTC that uses Swing pivots with its default settings