OPEN-SOURCE SCRIPT
Aggiornato

Fib Zone Screener

471
# Fib Zone Screener — TradingView publish description

## Title
Fib Zone Screener

## Short description (one-liner)
Flags when price is inside a Fibonacci retracement zone — direction-aware, so one setup works for both longs and shorts, and built to filter across a whole watchlist in the Pine Screener.

---

## Full description

**Fib Zone Screener** answers one question, per symbol, on every scan: *has price pulled back into a Fibonacci retracement zone right now — and is it a long or a short?*

It reads pure price action (no pivots, no moving averages, no `request.security`), so it stays fast enough to run across an entire watchlist in the **Pine Screener** while still drawing clean, readable zones on a single chart.

### How it works

For the chosen **Lookback**, the script finds the window's **highest high** and **lowest low**, then decides the swing direction from **which extreme is more recent**:

- **High is more recent** → the last leg was up → **long context** (a pullback is a dip to buy).
- **Low is more recent** → the last leg was down → **short context** (a pullback is a bounce to sell).

Retrace is always measured **from that most-recent extreme back toward the origin**, so the same zone numbers describe both sides:

```
Retrace 0.0 = at the extreme (no pullback)
0.5 = halfway back
0.618 = the golden ratio
0.786 = deep pullback
1.0 = fully retraced to the origin
```

Because the measurement flips with direction, **you set the zone once and it works for longs and shorts** — you don't need a separate short version or a mirrored scale.

### Three zones, three flags

The indicator returns three yes/no values — one per zone (all boundaries are inputs):

- **In Zone 1** — default **0.5 – 0.618** (the classic golden pullback zone)
- **In Zone 2** — default **0.618 – 0.786** (deeper pullback)
- **In Zone 3** — default **0.786 – 1.0** (very deep / near full retrace)

Each is `1` when price is inside that zone, `0` otherwise.

### On-chart drawing

The selected window's zones are drawn as **outlined boxes**, labelled with their ratios and colored by direction — **teal on the long side, red on the short side** — so a screener hit looks exactly like a hand-drawn fib. The boxes extend a few bars past the current candle so the latest wicks stay visible.

### Using it in the Pine Screener

1. Save the script and add it to your chart, then **star it as a favorite** — the Pine Screener only lists favorited indicators.
2. Open the **Pine Screener**, choose your watchlist and timeframe, and select **Fib Zone Screener**.
3. Add the columns you want (Manage Columns) and filter, for example:
- **Longs in the golden zone:** `Direction == 1` and `In Zone 1 == 1`
- **Shorts in the golden zone:** `Direction == -1` and `In Zone 1 == 1`
- **Deeper pullbacks:** use `In Zone 2 == 1`
4. Change the **Lookback** or any zone's **From/To** and re-scan to look at a different horizon or depth.

"Last N bars" means N bars of the **screener's timeframe** — scan on Daily for daily swings, on 1h for intraday.

### Screener columns

- **In Zone 1 / 2 / 3** — yes/no (1/0) per zone
- **Direction** — `1` long, `-1` short, `0` none
- **Extreme / Origin** — the swing's recent extreme and its starting point, in price
- **Zone 1/2/3 from $ · to $** — the actual price boundaries of each zone, so you can place orders straight from the scan

### Inputs

- **Lookback** — bars used to define the swing (default 100)
- **Zone 1/2/3 From / To** — retrace boundaries of each zone
- **Draw Zones On Chart** and **Extend Right (bars)** — display controls

### Notes

- Swing detection uses the two extreme points of the lookback window, so it reads the dominant range rather than every minor wiggle — deliberately simple, so it behaves identically across hundreds of symbols.
- No repainting from higher-timeframe requests — everything is computed on the chart's own bars.

Open source. Feedback and suggestions welcome.
Note di rilascio
# Fib Zone Screener — TradingView publish description

## Title
Fib Zone Screener

## Short description (one-liner)
Draws Fibonacci retracement zones for three lookback horizons at once — direction-aware, so one setup works for both longs and shorts — and filters across a whole watchlist in the Pine Screener. No higher-timeframe requests.

---

## Full description

**Fib Zone Screener** answers one question, per symbol, on every scan: *has price pulled back into a Fibonacci retracement zone right now — and is it a long or a short?* On the chart, it shows that answer across **three lookback horizons at once**.

It reads pure price action (no pivots, no moving averages, no `request.security`), so it stays fast enough to run across an entire watchlist in the **Pine Screener** while still drawing clean, readable zones on a single chart.

### Three views ≈ short / mid / long

A longer lookback captures a bigger swing, so a long lookback on your current chart approximates what a higher timeframe would show — the swing anchor points it finds are usually the same ones a higher-timeframe trader sees. The indicator uses this to draw **three lookback "views" at once** (defaults **100 / 200 / 400**), each with its own set of fib zones, giving you a short / mid / long (≈ intraday / daily / weekly) read on a single chart — **without any `request.security`**. The boxes nest (bigger lookback = wider box), so you can see at a glance whether the short-, mid-, and long-horizon structures agree.

### How it works

For each view's **lookback**, the script finds the window's **highest high** and **lowest low**, then decides the swing direction from **which extreme is more recent**:

- **High is more recent** → the last leg was up → **long context** (a pullback is a dip to buy).
- **Low is more recent** → the last leg was down → **short context** (a pullback is a bounce to sell).

Retrace is always measured **from that most-recent extreme back toward the origin**, so the same zone numbers describe both sides:

```
Retrace 0.0 = at the extreme (no pullback)
0.5 = halfway back
0.618 = the golden ratio
0.786 = deep pullback
1.0 = fully retraced to the origin
```

Because the measurement flips with direction, **you set the zone once and it works for longs and shorts** — you don't need a separate short version or a mirrored scale.

### Three zones, three flags

The core output is one yes/no per zone (all boundaries are inputs):

- **In Zone 1** — default **0.5 – 0.618** (the classic golden pullback zone)
- **In Zone 2** — default **0.618 – 0.786** (deeper pullback)
- **In Zone 3** — default **0.786 – 1.0** (very deep / near full retrace)

Each is `1` when price is inside that zone, `0` otherwise.

### Clean pullbacks

A pullback is "clean" when price is in a zone now **and** never dipped past that zone since the impulse extreme — a tidy, shallow retrace rather than one that overshot deep and bounced back. The **Clean Z1 / Clean Z2** flags capture exactly that, measuring the deepest retrace of *this* pullback only (a deep move before the swing began doesn't count). **Max Retr %** exposes that deepest value so you can set your own tolerance.

### On-chart drawing

Each enabled view's zones are drawn as thin **outlined boxes** in the view's **own color**, labelled with their lookback, direction, and ratios (e.g. `100 ▲ 0.5–0.618`). Direction is the **arrow** in the label — **▲ = long side, ▼ = short side** — so color stays free to identify the view. The boxes extend a few bars past the current candle so the latest wicks stay visible.

### Using it in the Pine Screener

1. Save the script and add it to your chart, then **star it as a favorite** — the Pine Screener only lists favorited indicators.
2. Open the **Pine Screener**, choose your watchlist and timeframe, and select **Fib Zone Screener**.
3. Add the columns you want (Manage Columns) and filter, for example:
- **Longs in the golden zone:** `Direction == 1` and `In Zone 1 == 1`
- **Shorts in the golden zone:** `Direction == -1` and `In Zone 1 == 1`
- **Clean longs (shallow pullback):** `Direction == 1` and `Clean Z1 == 1`
- **Deeper pullbacks:** use `In Zone 2 == 1`
4. Pick which view feeds the columns with **Flags From View** (default View 1 = the 100-bar horizon), or change any zone's **From/To**, and re-scan.

The screener stays **single-lookback** — it filters on the one view you select, while the chart still draws all three. "Last N bars" means N bars of the **screener's timeframe** — scan on Daily for daily swings, on 1h for intraday.

### Screener columns

- **In Zone 1 / 2 / 3** — yes/no (1/0) per zone
- **Clean Z1 / Clean Z2** — yes/no: price is in the zone now AND the pullback never dipped past that zone since the impulse extreme (a clean, shallow retrace — never reached the deeper zones during *this* swing)
- **Max Retr %** — the deepest retrace of the current pullback (since the extreme), for sorting/custom filters
- **Direction** — `1` long, `-1` short, `0` none
- **Extreme / Origin** — the swing's recent extreme and its starting point, in price
- **Zone 1/2/3 from $ · to $** — the actual price boundaries of each zone, so you can place orders straight from the scan

### Inputs

- **View 1/2/3** — enable + lookback for each horizon (defaults 100 / 200 / 400)
- **Flags From View** — which view drives the screener columns
- **Zone 1/2/3 From / To** — retrace boundaries of each zone (shared across views)
- **Draw Zones On Chart**, **Show Labels**, **Extend Right (bars)** — display controls
- **Show Info Box** + **Position** — a live corner readout translating each view's lookback (in bars) into a time span (days / weeks / months) based on the loaded timeframe's actual bars-per-day

### Notes

- Swing detection uses the two extreme points of each lookback window, so it reads the dominant range rather than every minor wiggle — deliberately simple, so it behaves identically across hundreds of symbols.
- No repainting and no higher-timeframe requests — everything is computed on the chart's own bars, including the "bigger horizon" views.

Open source. Feedback and suggestions welcome.

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.