OPEN-SOURCE SCRIPT

Confirmed Fibonacci (BOS + Pullback)

3 288
Confirmed Fib (BOS + Pullback) is an automated Fibonacci retracement indicator that draws a fib only after a complete structural sequence has confirmed on the chart. It is built for traders who use Fibonacci levels in the context of market structure rather than as a standalone tool drawn on every swing.

Most automatic Fibonacci indicators draw on every swing high and low they detect, producing a constant stream of overlapping levels that update bar-to-bar. Confirmed Fib works differently. The engine waits for three specific conditions to resolve in order — a prior pivot, a displacement leg that breaks the prior structural high or low, and a confirmed pullback pivot — before any fib is drawn. Until those conditions are met, the chart stays clean.

When a fib does draw, the anchors are locked. The 0.000 and 1.000 levels stay where they were placed and do not move as new highs and lows print. Each fib represents one specific structural moment and is removed from the chart when that structure invalidates, expires from inactivity, or conflicts with the higher-timeframe bias filter.

This indicator is a structural analysis tool. It does not generate buy or sell signals, predict reversals, or recommend entry or exit points. Trading decisions are the responsibility of the user.

How it works

The engine evaluates pivot points (default length 8 bars left and right) and tracks recent pivot history. A fib draws only when all three of the following resolve in order:

A prior pivot exists — the structure has a starting reference (the 1.000 anchor)
An impulse leg breaks structure — price moves from that prior pivot and breaks through the most recent prior structural high (bull) or low (bear). This is the Break of Structure
A pullback pivot confirms — price retraces from the impulse extreme and forms a new pivot in the opposite direction. This is the third anchor that triggers the draw

The impulse leg must also meet a minimum size (default 1.5 × ATR(14)) to filter out weak or insignificant moves. When all conditions resolve, the fib is anchored from the prior pivot (1.000) to the impulse extreme (0.000) and stays locked at those prices. Bear setups follow the mirrored logic.
Higher timeframe bias filter (optional)
A separate check requires the next standard timeframe up to be in alignment before a fib can draw. The filter auto-resolves based on the chart timeframe:

Charts below 1H → checks the 1H
1H to 3H → checks the 4H
4H → checks the Daily
Daily → checks the Weekly
Weekly → checks the Monthly
Monthly → filter unavailable (no higher TF)

The HTF bias is determined by pivot structure on that timeframe (last pivot pair vs. prior pivot pair: HH+HL = bull, LH+LL = bear). If the HTF flips against an active fib, the structure is cleared.
Removal conditions
An active fib is removed when one of the following happens:

Price closes beyond the anchor by more than the invalidation buffer (default 0.25 × ATR)
The leg ages out without anchor refresh (default 150 bars)
The HTF bias filter flips against the active direction

Section 3 — How to use

The indicator stays silent until a valid structure forms. When a fib draws, the chart shows the seven Fibonacci retracement levels, the 0.618–0.786 golden zone (highlighted with a fill), a diagonal dashed line connecting the prior pivot to the impulse extreme, and labelled HH/HL or LH/LL anchor markers showing the exact anchor prices.

The Golden Zone (0.618–0.786)
The 0.618–0.786 area is highlighted as the golden zone. This is the deeper retracement region where many trend-following traders monitor for the pullback to complete before the trend resumes. The golden zone is one input among many — confirmation, broader context, and risk management remain the user's responsibility.

The Dashboard
A panel in the top right reports four readings:

Structure — current state of the engine. Possible values include Active — Bull Structure, Active — Bear Structure, No Active Structure, Bull/Bear Structure Broken, Conflict with Higher Timeframe, Structure Expired
Higher Timeframe Bias — direction of the auto-resolved HTF in plain text (e.g. Bull (4H), Bear (Daily))
Anchor High / Anchor Low — the exact prices the fib is locked to
Pullback Formed — how many bars ago the pullback pivot confirmed. This is a freshness indicator: small numbers mean the setup is fresh, large numbers mean the entry window may have already passed

Alerts
Two alerts are built in:

New fib drawn — fires the bar a new bull or bear structure validates
Golden Zone touch — fires once per setup, the moment price first enters the 0.618–0.786 zone. Resets each time a new fib draws

To use them, right-click the chart, choose Add alert, set Condition to Confirmed Fib (BOS + Pullback), and select Any alert() function call. Both alerts can be toggled independently from the indicator settings.


Section 4 — Settings guide

Structure

Pivot length (L/R) — bars to the left and right used to detect a pivot. Suggested: 15m → 18, 1H → 8, 4H → 4, Daily → 3. Higher = stricter pivots, slower to confirm
Min displacement (ATR) — minimum impulse leg size in ATR(14) units. Default 1.5. Lower values produce more fibs at lower quality. Higher values produce fewer, cleaner setups
Invalidation buffer (ATR) — wick tolerance applied to the anchor invalidation rule. Default 0.25. Increase if you want fewer false invalidations on volatile instruments
Max leg age (bars) — auto-clears the structure after this many bars without new anchors. Default 150
Pivots retained — how many recent pivots the engine keeps in memory. Default 15. Rarely needs adjustment

HTF Bias

Use HTF bias filter — on/off toggle for the higher-timeframe alignment requirement
HTF pivot length (L/R) — pivot strictness on the higher timeframe. Default 3. Use 5 for stricter, 2 for faster bias detection

Fib Levels — toggle each individual level on/off (0.000, 0.236, 0.382, 0.500, 0.618, 0.786, 1.000)
Visual

Colour pickers for the fib lines, the 0.500 mid-line, the golden zone fill and edge, and the impulse line
Toggles for: extending lines to the right, price labels, anchor markers, the impulse line, and the info panel

Alerts

Alert on new fib drawn — on/off
Alert on Golden Zone touch — on/off



Section 5 — Important notes


The fib draws after the structural moment, not at it. The pullback condition requires confirmation bars to its right, so the fib appears once the pullback pivot is confirmed. By the time a fib draws, price may already be inside or past the golden zone. The "Pullback Formed" reading on the dashboard tells you how stale the setup is.

Each new valid pullback in the same trend can produce a new fib. This is intentional — each fib represents one specific structural opportunity. To reduce redraws in strong trending conditions, increase the Min displacement setting.

Anchors lock when a fib draws. The 0.000 and 1.000 levels do not move bar-to-bar. This is what makes the levels usable as fixed reference points.

The HTF bias filter only blocks new fibs and resets active ones on conflict. It does not change how the levels are calculated.
This indicator does not predict reversals, generate entry or exit signals, or replace risk management. It detects and visualises structural pullback setups. All trading decisions are the responsibility of the user.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.