OPEN-SOURCE SCRIPT

Trend Fib Zone Bounce (TFZB) [KedArc Quant]

139
Description:

Trend Fib Zone Bounce (TFZB) trades with the latest confirmed Supply/Demand zone using a single, configurable Fib pullback (0.3/0.5/0.6). Trade only in the direction of the most recent zone and use a single, configurable fib level for pullback entries.
• Detects market structure via confirmed swing highs/lows using a rolling window.
• Draws Supply/Demand zones (bearish/bullish rectangles) from the latest MSS (CHOCH or BOS) event.
• Computes intra zone Fib guide rails and keeps them extended in real time.
• Triggers BUY only inside bullish zones and SELL only inside bearish zones when price touches the selected fib and closes back beyond it (bounce confirmation).
• Optional labels print BULL/BEAR + fib next to the triangle markers.

What it does
Finds structure using confirmed swing highs/lows (you choose the confirmation length).
Builds the latest zone (bullish = demand, bearish = supply) after a CHOCH/BOS event.
Draws intra-zone “guide rails” (Fib lines) and extends them live.
Signals only with the trend of that zone:
BUY inside a bullish zone when price tags the selected Fib and closes back above it.
SELL inside a bearish zone when price tags the selected Fib and closes back below it.
Optional labels print BULL/BEAR + Fib next to triangles for quick context

Why this is different

Most “zone + fib + signal” tools bolt together several indicators, or fire counter-trend signals because they don’t fully respect structure. TFZB is intentionally minimal:
Single bias source: the latest confirmed zone defines direction; nothing else overrides it.
Single entry rule: one Fib bounce (0.3/0.5/0.6 selectable) inside that zone—no counter-trend trades by design.
Clean visuals: you can show only the most recent zone, clamp overlap, and keep just the rails that matter.
Deterministic & transparent: every plot/label comes from the code you see—no external series or hidden smoothing

How it helps traders

Cuts decision noise: you always know the bias and the only entry that matters right now.
Forces discipline: if price isn’t inside the active zone, you don’t trade.
Adapts to volatility: pick 0.3 in strong trends, 0.5 as the default, 0.6 in chop.
Non-repainting zones: swings are confirmed after Structure Length bars, then used to build zones that extend forward (they don’t “teleport” later)

How it works (details)

*Structure confirmation
A swing high/low is only confirmed after Structure Length bars have elapsed; the dot is plotted back on the original bar using offset. Expect a confirmation delay of about Structure Length × timeframe.
*Zone creation
After a CHOCH/BOS (momentum shift / break of prior swing), TFZB draws the new Supply/Demand zone from the swing anchors and sets it active.
*Fib guide rails
Inside the active zone TFZB projects up to five Fib lines (defaults: 0.3 / 0.5 / 0.7) and extends them as time passes.
*Entry logic (with-trend only)
BUY: bar’s low ≤ fib and close > fib inside a bullish zone.
SELL: bar’s high ≥ fib and close < fib inside a bearish zone.
*Optionally restrict to one signal per zone to avoid over-trading.
(Optional) Aggressive confirm-bar entry


When do the swing dots print?

* The code confirms a swing only after `structureLen` bars have elapsed since that candidate high/low.
* On a 5-min chart with `structureLen = 10`, that’s about 50 minutes later.
* When the swing confirms, the script plots the dot back on the original bar (via `offset = -structureLen`). So you *see* the dot on the old bar, but it only appears on the chart once the confirming bar arrives.

> Practical takeaway: expect swing markers to appear roughly `structureLen × timeframe` later. Zones and signals are built from those confirmed swings.

Best timeframe for this Indicator

Use the timeframe that matches your holding period and the noise level of the instrument:
* Intraday :
* 5m or 15m are the sweet spots.
* Suggested `structureLen`:
* 5m: 10–14 (confirmation delay \~50–70 min)
* 15m: 8–10 (confirmation delay \~2–2.5 hours)
* Keep Entry Fib at 0.5 to start; try 0.3 in strong trends, 0.6 in chop.
* Tip: avoid the first 10–15 minutes after the open; let the initial volatility set the early structure.

* Swing/overnight:
* 1h or 4h.
* `structureLen`:
* 1h: 6–10 (6–10 hours confirmation)
* 4h: 5–8 (20–32 hours confirmation)

* 1m scalping: not recommended here—the confirmation lag relative to the noise makes zones less reliable.

Inputs (all groups)
Structure
• Show Swing Points (structureTog)
o Plots small dots on the bar where a swing point is confirmed (offset back by Structure Length).
• Structure Length (structureLen)
o Lookback used to confirm swing highs/lows and determine local structure. Higher = fewer, stronger swings; lower = more reactive.
Zones
• Show Last (zoneDispNum)
o Maximum number of zones kept on the chart when Display All Zones is off.
• Display All Zones (dispAll)
o If on, ignores Show Last and keeps all zones/levels.
• Zone Display (zoneFilter): Bullish Only / Bearish Only / Both
o Filters which zone types are drawn and eligible for signals.
• Clean Up Level Overlap (noOverlap)
o Prevents fib lines from overlapping when a new zone starts near the previous one (clamps line start/end times for readability).

Fib Levels

Each row controls whether a fib is drawn and how it looks:
• Toggle (f1Tog…f5Tog): Show/hide a given fib line.
• Level (f1Lvl…f5Lvl): Numeric ratio in [0,1]. Defaults active: 0.3, 0.5, 0.7 (0 and 1 off by default).
• Line Style (f1Style…f5Style): Solid / Dashed / Dotted.
• Bull/Bear Colors (f#BullColor, f#BearColor): Per-fib color in bullish vs bearish zones.
Style
• Structure Color: Dot color for confirmed swing points.
• Bullish Zone Color / Bearish Zone Color: Rectangle fills (transparent by default).
Signals
• Entry Fib for Signals (entryFibSel): Choose 0.3, 0.5 (default), or 0.6 as the trigger line.
• Show Buy/Sell Signals (showSignals): Toggles triangle markers on/off.
• One Signal Per Zone (oneSignalPerZone): If on, suppresses additional entries within the same zone after the first trigger.
• Show Signal Text Labels (Bull/Bear + Fib) (showSignalLabels): Adds a small label next to each triangle showing zone bias and the fib used (e.g., BULL 0.5 or BEAR 0.3).

How TFZB decides signals
With trend only:
• BUY
1. Latest active zone is bullish.
2. Current bar’s close is inside the zone (between top and bottom).
3. The bar’s low ≤ selected fib and it closes > selected fib (bounce).
• SELL
1. Latest active zone is bearish.
2. Current bar’s close is inside the zone.
3. The bar’s high ≥ selected fib and it closes < selected fib.
Markers & labels
• BUY: triangle up below the bar; optional label “BULL 0.x” above it.
• SELL: triangle down above the bar; optional label “BEAR 0.x” below it.

Right-Panel Swing Log (Table)

What it is
A compact, auto-updating log of the most recent Swing High/Low events, printed in the top-right of the chart.
It helps you see when a pivot formed, when it was confirmed, and at what price—so you know the earliest bar a zone-based signal could have appeared.

Columns

Type – Swing High or Swing Low.
Date – Calendar date of the swing bar (follows the chart’s timezone).
Swing @ – Time of the original swing bar (where the dot is drawn).
Confirm @ – Time of the bar that confirmed that swing (≈ Structure Length × timeframe after the swing). This is also the earliest moment a new zone/entry can be considered.
Price – The swing price (high for SH, low for SL).

Why it’s useful

Clarity on repaint/confirmation: shows the natural delay between a swing forming and being usable—no guessing.
Planning & journaling: quick reference of today’s pivots and prices for notes/backtesting.
Scanning intraday: glance to see if you already have a confirmed zone (and therefore valid fib-bounce entries), or if you’re still waiting.
Context for signals: if a fib-bounce triangle appears before the time listed in Confirm @, it’s not a valid trade (you were too early).
Settings (Inputs → Logging)
Log swing times / Show table – turn the table on/off.
Rows to keep – how many recent entries to display.
Show labels on swing bar – optional tags on the chart (“Swing High 11:45”, “Confirm SH 14:15”) that match the table.

Recommended defaults
• Structure Length: 10–20 for intraday; 20–40 for swing.
• Entry Fib for Signals: 0.5 to start; try 0.3 in stronger trends and 0.6 in choppier markets.
• One Signal Per Zone: ON (prevents over trading).
• Zone Display: Both.
• Fib Lines: Keep 0.3/0.5/0.7 on; turn on 0 and 1 only if you need anchors.

Alerts
Two alert conditions are available:
• BUY signal – fires when a with trend bullish bounce at the selected fib occurs inside a bullish zone.
• SELL signal – fires when a with trend bearish bounce at the selected fib occurs inside a bearish zone.
Create alerts from the chart’s Alerts panel and select the desired condition. Use Once Per Bar Close to avoid intrabar flicker.

Notes & tips
• Swing dots are confirmed only after Structure Length bars, so they plot back in time; zones built from these confirmed swings do not repaint (though they extend as new bars form).
• If you don’t see a BUY where you expect one, check: (1) Is the active zone bullish? (2) Did the candle’s low actually pierce the selected fib and close above it? (3) Is One Signal Per Zone suppressing a second entry?
• You can hide visual clutter by reducing Show Last to 1–3 while keeping Display All Zones off.

Glossary
• CHOCH (Change of Character): A shift where price breaks beyond the last opposite swing while local momentum flips.
• BOS (Break of Structure): A cleaner break beyond the prior swing level in the current momentum direction.
• MSS: Either CHOCH or BOS – any event that spawns a new zone.

Extension ideas (optional)
• Add fib extensions (1.272 / 1.618) for target lines.
• Zone quality score using ATR normalization to filter weak impulses.
• HTF filter to only accept zones aligned with a higher timeframe trend.


⚠️ Disclaimer This script is provided for educational purposes only.
Past performance does not guarantee future results.
Trading involves risk, and users should exercise caution and use proper risk management when applying this strategy.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.