Swing trend
Up while swing highs and lows both rise, down while both fall.
Swing trend from the last two confirmed pivot highs and lows (swing params as swing). Judged on each pivot confirmation with b = max(floor_pct % × close, trend_k × ATR before the candle): up = both the newer high and the newer low are more than b above the older ones; down is the mirror; held until the next confirmation. Both 0 = mixed. Not ready until two highs and two lows exist.
Swing trend is a structure detector: it marks price structure on the chart and counts against the plan's detector limit.
Settings
| Setting | Default | Range | What it does |
|---|---|---|---|
| atr_period | 14 | 1 to 500 | ATR length (Wilder) for every buffer. |
| swing_k | 2 | 0.1 to 20 | Swing reversal in ATRs: a pivot is confirmed when a close moves this far back. |
| swing_min_pct | 0.1 | 0 to 10 | Smallest swing reversal, % of the close. |
| trend_k | 0.1 | 0 to 5 | A higher high or low must clear the earlier one by this many ATRs. |
| floor_pct | 0.02 | 0 to 10 | Smallest buffer of this detector, % of the close (each buffer is the larger of this and its ATR multiple). |
What it gives
| Output | What it is |
|---|---|
| Up trend | True while swing highs and lows are rising. |
| Down trend | True while swing highs and lows are falling. |
What it reads
It reads the whole candle (open, high, low, close and volume).
Warm-up
With its default settings, Swing trend needs 241 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 trend with its default settings