OPEN-SOURCE SCRIPT

Anchor S&R Suite - Fib Levels

383
Anchor S&R Suite — Fib Levels
Anchored Fibonacci retracements & projections that recompute on a higher-time-frame rhythm and never repaint.

Instead of dragging a fib tool by hand between a swing high and a swing low, this indicator measures a reference range automatically — the High/Low (or Open/Close) of one or several CLOSED higher-time-frame (HTF) candles — and plots the full Fibonacci ladder from it, across your entire chart history. The result is a clean, repeatable level grid that updates on a predictable rhythm and never moves under your feet.


WHAT MAKES IT DIFFERENT

• Anchored to a time frame, not a manual swing. You choose the cadence (e.g. Weekly); the levels are recomputed once per closed HTF candle and held perfectly flat until the next one closes — clean horizontal steps, not sloping diagonals.

• Zero repaint. The indicator only ever reads candles that have already CLOSED. During the current, still-forming HTF period the levels are based on the previous period and do not move — not on every tick, not on every chart bar. A level you saw an hour ago sits in the exact same place now, so what you backtest by eye is what you would have traded.

• Warm-up, not repaint. The only caveat: the first levels can appear only once enough closed HTF candles exist (exactly like a moving average needs its length in bars). No historical value is ever rewritten — loading more history simply reveals earlier levels.


HOW IT WORKS

On the close of every cadence candle, the indicator takes the range of the last closed candle(s) and rebuilds the ladder from it. That ladder stays fixed until the next cadence close, when it jumps to the new values.

• Retracement levels sit INSIDE the range — the pullback / continuation zones you watch while price works within an established range.
• Projection levels sit OUTSIDE the range — measured-move / breakout targets for when price leaves the range.

The deliberate one-bar gap you see at each boundary is intentional: it marks the bar where a new HTF candle closed and the ladder was recomputed. It is the visual signature of a correctly anchored, non-repainting level — not a glitch.


THE CALCULATION

Let mergeHi and mergeLo be the high and low of the anchored window, and H = mergeHi − mergeLo its height. For a ratio f, the four directions are:

• Retracement from the high : mergeHi − f × H (descends into the range)
• Retracement from the low : mergeLo + f × H (rises into the range)
• Projection above the high : mergeHi + f × H (extends upward)
• Projection below the low : mergeLo − f × H (extends downward)

At f = 0 a level sits on its anchor; at f = 1 it reaches the opposite end of the range. So 0 and 1 are the range bounds (the decision zone lives between them, 0.382–0.786). Ratios are not limited to 0–1: a value above 1 (e.g. 1.272, 1.618) projects beyond the range as an extension target.


SETTINGS

• Cadence TF — the heartbeat. It controls both which range the fibs are measured from and how often they refresh. Higher cadence = fewer, wider, slower levels (a macro map); lower cadence = tighter, more reactive levels. Must be greater than the chart TF.

• Lookback (1–20) — how many closed HTF candles merge into ONE range. 1 = the last period only (maximum reactivity); 4 (default) = the highest high / lowest low of the last four (broader, calmer, anchored to more structure).

• Source — High/Low (full candle range, wicks included; captures the true extremes) or Open/Close (bodies only, ignores wicks; tighter, “accepted-value” levels).

• Fib Mode — Retracement / Projection / Both. It also greys out the inputs of the family it excludes.

• 7 levels — each row gives INDEPENDENT control over its Retracement and its Projection: a toggle plus a fully editable ratio for each family, side by side. So any level can be a retracement, a projection, both, or neither, each with its own value. The classic 0.382 / 0.5 / 0.618 / 0.786 are shown by default; 0 / 0.236 / 1 are available. Edit any value to match your method (an OTE-style 0.705, a 0.65, or a 1.618 extension).

• Display — independent show/hide and colour for the Upper family, the Lower family and the Range lines; level & range line widths; optional per-level ratio labels.

istantanea
Lookback = 1 — the last closed period only (tight, reactive).

istantanea
Lookback = 4 (default) — a broader, calmer range over four periods.

istantanea
Retracement / Projection / Both.


HOW TO TRADE THE LEVELS

The indicator draws the map; you decide. A level is a decision point, not a guarantee.

• Confluence first. A level matters most when several things agree at the same price: a retracement and a projection landing together, a level sitting on a prior swing high/low or a round number. The more overlap, the stronger the reaction tends to be.
• React, don’t predict. Watch HOW price behaves at a level — a rejection wick, a reclaim, a tight consolidation — rather than assuming it must stop there.
• Entries. In a pullback, continuation entries tend to cluster around 0.5 / 0.618 / 0.786; wait for a reaction rather than a blind limit on the line.
• Stops & targets. A stop just beyond the next level (where the idea is invalidated); targets at the opposite retracements, the range bounds, or the projection extensions (0.618 / 1.0 / 1.618).
• Bias from the range. Holding above the 0.5 of the range reads as relative strength; losing the deep 0.786 suggests the pullback is failing.


EXAMPLE SETUPS

• Swing (default): chart 1h–4h, Cadence = Weekly, Lookback = 4, Source = High/Low, Mode = Retracement. The multi-week range frames the swing; the internal retracements mark where to add or fade.
• Intraday off the prior day: chart 5–15m, Cadence = Daily, Lookback = 1, Mode = Both. Prior-day range as anchors, internal retracements as pullback zones, projections as breakout targets.
• Macro context: chart Daily, Cadence = Monthly, Lookback = 1. A slow, stable map of monthly value for bias.

Works on any market and any timeframe.

This indicator is a charting / analysis tool. It is not financial advice and does not generate buy or sell signals.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.