OPEN-SOURCE SCRIPT

50% Fib Trend Cloud + ATR Bands

267
This indicator plots two structural 50% fibonacci midpoints from recent confirmed 'left/right' swings that form a *cloud* of equilibrium, then adds a rolling 50% fibonacci range midpoint based on a lookback window that's wrapped in ATR bands. Importantly, it solves a specific trading problem:

Structural midpoints (macro context) are powerful but can lag when price escapes prior ranges. Enter rolling 50% fib + ATR ➡️ which restores real-time balance & tolerance (micro context). Together they show where price is balanced structurally, where it’s balanced right now, and how much volatility to tolerate before acting.

➖➖➖

🔑 Why this is different
Most tools either draw a single midpoint (ex., daily 50%) or ATR bands around a moving average. This script fuses dual swing-based 50% midpoints (structure) + a rolling 50% with ATR (flow), so you don’t lose context when price escapes prior ranges. The cloud tells you who’s in control (fast vs. slow structure). The rolling 50% + ATR tells you how far is “too far” now.

➖➖➖

🧠 What it does (at a glance)
🔸Structural Equilibrium × 2 (Fib1/Fib2)
Two independent 50% midpoints formed from swing pivots (configurable Left/Right bars + optional smoothing). Their gap is the Midpoint Cloud = structural “fair value” zone.
🔸Rolling 50% + ATR Bands
A rolling highest/lowest window computes an always-current 50% rolling midpoint plot; ±ATR × length envelopes define a soft value area and over-stretch boundaries.
🔸Actionable Visuals
Optional fill between Fib1/Fib2, labels, and candle-overlay modes to instantly read regime (above both / below both / between).
🔸Smart Defaults
Timeframe-aware presets for L/R pivots & smoothing; full manual overrides available.

➖➖➖

⚙️ Calculations (plain-English)
🔸Pivot midpoints (Fib1 & Fib2):
1) Detect a swing using `Left/Right` bars
2) Take the swing’s high/low → compute 50%
3) (Optional) Smooth the line (SMA) to stabilize on noisy TFs
4) Repeat with a different sensitivity to get two distinct midpoints
🔸Rolling midpoint:
Highest High / Lowest Low over the last *N* bars → (HH + LL) / 2
🔸ATR levels:
`Upper = Rolling50 + ATR × Mult`, `Lower = Rolling50 − ATR × Mult`
(Typical: ATR length 14–21; Multipliers 2.236 for L1, 5.382 for L2)

➖➖➖

🤖 Auto-Configured Presets (with Manual Override)

💡Goal: make the midpoints “just work” on common timeframes while still letting you dial them in.

💡How Auto Presets work
When Auto Presets = ON, the script picks sensible L/R/S (Left bars / Right bars / Smoothing) for Fib Trend 1 and Fib Trend 2 based on chart timeframe.
🔸Fib 1 (fast) emphasizes *micro-structure* for quicker bias shifts.
🔸Fib 2 (slow) emphasizes *macro-structure* for anchor/bias context.
These defaults keep Fib 1 responsive without jitter and Fib 2 stable without lag.

➡️ Turn Auto Presets = OFF to take full control with the manual inputs described below.

➖➖➖

🛠 Manual Fib Midpoint Settings (when Auto = OFF)

💡Each midpoint uses three knobs:
🔸Pivot Left (L): bars to the left that must be lower/higher to qualify a swing
🔸Pivot Right (R): bars to the right that must be lower/higher to confirm the swing
🔸Smoothing (S): SMA period applied to the raw 50% midpoint (stabilizes noise)

5-Minute optimized defaults
🔸Fib Trend 1: `L21 / R5 / S55` → responsive local structure (entries/exits, re-balancing zones)
🔸Fib Trend 2: `L55 / R13 / S89` → broader structure (trend context, anchors/stops)

Timeframe guidance
🔸1m–3m: may feel a touch laggy → consider ~`L13 / R3 / S34`
🔸15m–1h: defaults remain strong → optionally ~`L34 / R8 / S89`
🔸4h+ : increase span for stability → `L89–144 / R13–21 / S144–233`

➡️ Rule of thumb: shorter L/R = faster detection, longer S = smoother line. Tune until Fib 1 captures the “active swing” and Fib 2 captures the “dominant swing” without whipsaw.

➖➖➖

🎛 Inputs (quick reference)
🔸Fib Trend 1/2: Source (High/Low/Close), Left/Right bars, Smoothing length, Show/Hide, Cloud fill toggle
🔸Rolling 50%: Lookback length, Price basis (Wicks/Close/HLC3/OHLC4), Plot scope (Full / Last N / None)
🔸ATR Bands: ATR length, Multipliers (L1/L2), Plot scope, Line width/colors
🔸Overlay & Labels: Candle overlay mode, Label padding/size, 50% centerline toggle, Plot widths

➖➖➖

🖍️ Candle Coloring & Overlay Modes

💡Purpose: make trend instantly visible on the candles and ATR levels.

1) Color Logic (dropdown)
🔸 Fib Midpoints — Colors by position of price vs. Fib 1 & Fib 2
🔸ATR Zones — Colors by which ATR zone price is in relative to the Rolling 50%

➡️ Price Reference: Choose the input used for the decision (Close, HL2, OHLC3, OHLC4).
➡️Tip: Close is crisp; HL2/OHLC variants are smoother.

2) Overlay Style (dropdown)
🔸 None — No visual change to candles
🔸 Bar Color — Uses `barcolor()` to tint built-in candles (this takes into account your Trading View settings, for instance if you have wicks set to white, they will show up as white with this setting)
🔸 PlotCandles — Draws unified custom candles (body, wick, border) with the same color for maximum clarity

💡Practical use
🔸 Pick Fib Midpoints to read structural bias at a glance (above/below/between the cloud).
🔸 Pick ATR Zones to read value vs. stretch around the Rolling 50% (mean-reversion vs. trend extension).

➖➖➖

📘 How to use
A) Trend confirmation
- Strong bullish bias when price holds above both structural mids; strong bearish when below both.
- Use the Rolling 50% + ATR as a dynamic re-entry zone: pullbacks that respect ATR(L1) often continue the prevailing trend.

B) Transition / mean reversion
- Inside the Cloud (between Fib1 & Fib2) treat behavior as neutralization/re-balancing; range tactics tend to outperform momentum plays.
- In ranges, fades near ±ATR around the rolling 50% can mark short-term edges.

C) Breakout context
- When price leaves the Cloud, the Rolling 50% keeps you anchored so price never feels “floating.” A clean hold outside ATR(L1/L2) suggests regime strength; quick re-entries hint at traps.

➖➖➖

🖼 Chart examples
➡️ Each snapshot shows how the Cloud (structure) and the Rolling 50% + ATR (flow) work together.

1) 1-Minute Downtrend – Cloud as Dynamic Ceiling
- The Cloud slopes down; pullbacks repeatedly fail under the Cloud’s underside.
- Rolling 50% (dashed mid) + ATR(L1) act as a reversion band: rallies stall near upper ATR and rotate lower.
Snapshot

2) 15-Minute Persistent Drift – Structure Guides, Flow Times Entries
- Long drift lower with Cloud overhead.
- Consolidations near the rolling mid resolve in the trend direction; ATR bands frame risk on each attempt.
Snapshot

3) 15-Minute Uptrend (BTC) – From Cloud Escape to Value Stair-Step
- After escaping the prior Cloud, rolling 50% + ATR establish a new higher value area.
- Pullbacks into ATR(L1) produce orderly stair-steps; Cloud remains supportive on deeper dips
Snapshot

4) 5-Minute BTC – Pullback to Value then Rotate
- Strong leg up; retrace tags lower ATR band and rotates back toward the rolling mid.
- Labels (Fib1/Fib2) make the structural context explicit for decision-making.
Snapshot

➖➖➖

🧪 Starter presets
- Intraday (5–15m): Fib1 ~ L21/R5 (smooth 5), Fib2 ~ L55/R13 (smooth 9) • Rolling = 55 • ATR = 14 • L1 = 2.5x, L2 = 5.0x
- Scalping: Shorten lookbacks & smoothing; keep ATR multipliers similar, or tighten L1.
- Swing: Lengthen all lookbacks; consider ATR length 21–28.

➖➖➖

🏁Final Word

This script is not just a visual tool, it’s a complete trend and structure framework. Whether you're looking for clean trend alignment, dynamic support/resistance, or early warning signs of a reversal, this system is tuned to help you react with confidence — not hindsight.

Rembember, no single indicator should be used in isolation. For best results, combine it with price action analysis, higher-timeframe context, and complementary tools like trendlines, moving averages etc Use it as part of a well-rounded trading approach to confirm setups — not to define them alone.

---

💡Turn logic into clarity. Structure into trades. And uncertainty into confidence.

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.