How it is calculated
Swings as in structure. The leg runs from the older of the last swing high and low to the newer: up when the high is newer. Each level is end minus ratio times (end minus start), so level_0 is the leg's end, level_1000 its start and level_618 the 0.618 retracement. leg is +1 for an up leg, -1 for a down leg.
Reference: Fibonacci retracement of the last swing leg (#546)
How to read it
The levels move when a new swing is confirmed, length bars after its extreme, and hold until the next one. In an up leg the levels sit below the high, in a down leg above the low; nothing shows before the first swing high and low.
In a strategy
Buy a pullback in an up leg: when f = ctx.ind("fib_retracement", length=3) has f.leg of 1, a long limit at f.level_618 with the stop below f.level_1000, the leg's low.
Inputs
| Input | Type | Default | Range or choices |
|---|---|---|---|
Swing bars each sidelength | Whole number | 3 | min 1, max 50 |
What it draws
| Line | Drawn as |
|---|---|
| 0 | Steps |
| 0.236 | Steps |
| 0.382 | Steps |
| 0.5 | Steps |
| 0.618 | Steps |
| 0.786 | Steps |
| 1 | Steps |
Used in
No strategy template reads it yet.