Tool
Auto Fibonacci Levels
market.fibonacci_levels
Inputs
No typed inputs.
Outputs
A bundle with a per-bar validity gate plus one stepped price series per enabled level — each line re-anchors when a new pivot becomes visible. Chart them directly, or gate conditions on price touching a level; for TP/SL prices use the Anchor + Retracement pair instead.
Auto Fibonacci Levels draws the classic retracement ladder by itself: it finds the swings with a ZigZag scan of the chart, anchors on the latest impulse or pullback leg, and paints up to 12 percent levels as stepped lines that re-anchor whenever a new swing prints — TradingView’s “Auto Fib Retracement” as a chartable node.
How it works
A MetaTrader-style ZigZag pass (depth / deviation_points / backstep / point_value) turns the chart’s own highs and lows into alternating swing pivots. At each bar the tool looks only at the pivots visible so far, selects the anchoring leg with the exact same rules as Fibonacci Anchor (mode decides confirmed vs still-forming, leg_select picks the impulse or the pullback), and broadcasts every configured percent level as price = end + (start − end) × (pct / 100), held constant until the next pivot becomes visible. 0% sits at the leg’s end (the most recent extreme), 100% at its start. The levels are per-bar series meant for charting and gating; to wire fixed level PRICES into order TP/SL slots, use Fibonacci Anchor plus Fibonacci Retracement instead.
Modes
Mode options
Anchors only on the last CLOSED pivot pair — the trailing provisional pivot is dropped, so the drawn levels stay put as new bars print.
When to use: The stable default for backtests and live gating: the ladder never shifts under your feet.
Also admits the still-forming trailing leg, so the ladder re-draws while the newest swing keeps extending (it repaints, honestly).
When to use: Live-chart reading when you want the freshest anchor and accept moving levels.
Leg select options
Anchors on the older, driving leg of the trailing swing pair — the displacement most traders stretch their fib over.
When to use: The classic auto-fib behavior: measure the pullback against the move that caused it.
Anchors on the newer leg — the pullback itself — so the levels project off the correction instead of the drive.
When to use: Continuation setups: watch how far price re-traces the pullback, not the impulse.
Level count options
Configuration
Which legs qualify as anchors. confirmed uses only closed pivot pairs (stable); latest also tracks the leg still forming (repaints).
Which leg of the trailing swing pair to stretch the ladder over: impulse = the older, driving leg; retrace = the newer pullback.
ZigZag: the minimum number of bars a swing must span before a new pivot can form — higher values keep only the larger swings.
ZigZag: the minimum reversal, in points, required to register a new pivot. Converted to a price distance via point_value.
ZigZag: the minimum number of bars between two consecutive pivots, preventing pivots from clustering on adjacent bars.
The price size of one point for this symbol, used to convert deviation_points into an actual price distance (e.g. 0.0001 for a 5-digit FX pair).
How many level lines to draw, from 1 up to 12. The default 10 is MT5’s classic preset plus the TradingView/ICT-standard 78.6. Only the first level_count of the level_N_pct percents are used.
Percent for level #0: 0 = the leg’s end, 100 = its start, values above 100 project beyond the start. Default 0.
Percent for level #1: 0 = the leg’s end, 100 = its start, values above 100 project beyond the start. Default 23.6.
Percent for level #2: 0 = the leg’s end, 100 = its start, values above 100 project beyond the start. Default 38.2.
Percent for level #3: 0 = the leg’s end, 100 = its start, values above 100 project beyond the start. Default 50.
Percent for level #4: 0 = the leg’s end, 100 = its start, values above 100 project beyond the start. Default 61.8.
Percent for level #5: 0 = the leg’s end, 100 = its start, values above 100 project beyond the start. Default 78.6.
Percent for level #6: 0 = the leg’s end, 100 = its start, values above 100 project beyond the start. Default 100.
Percent for level #7: 0 = the leg’s end, 100 = its start, values above 100 project beyond the start. Default 161.8.
Percent for level #8: 0 = the leg’s end, 100 = its start, values above 100 project beyond the start. Default 261.8.
Percent for level #9: 0 = the leg’s end, 100 = its start, values above 100 project beyond the start. Default 423.6.
Percent for level #10. Default 0 (an extra slot — raise it to add your own level).
Percent for level #11. Default 0 (an extra slot — raise it to add your own level).
Connects to
Examples
- Drop it on any chart to get TradingView-style auto fib levels — no wiring: it detects the swings itself.
- Gate longs to bars where close dips under the 61.8% line of the latest confirmed up-impulse (wire level_4 into a threshold condition).
Common mistakes
- Expecting the level outputs to plug into order TP/SL slots — they are per-bar series; the SCALAR path is Fibonacci Anchor + Fibonacci Retracement.
- Using mode=latest in a backtest and mistaking its repainting ladder for the stable confirmed one.