OPEN-SOURCE SCRIPT
Automatic Fibonacci Retracement Levels (MTF)

Automatic Fibonacci Retracement Levels (MTF)
Auto-anchored Fibonacci retracement levels drawn between the most recent confirmed swing high and swing low, replicated across up to three higher timeframes. As new pivots form on each timeframe, the levels reanchor automatically — no manual redrawing every time the swing range changes.
The point is to see Fibonacci structure across multiple horizons on a single chart, without juggling drawing tools.
How it works
For each of the three configured timeframes, the script runs a pivot detector inside request.security (with lookahead_off, so no future-data leak). The most recent confirmed swing high and swing low per timeframe are stored as the active anchors. Standard ratios — 0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, 100% — are computed between low and high, with optional extensions at 127.2%, 161.8%, 200%, and 261.8% beyond the 100% pivot.
A proximity filter compares each individual level to current close and hides anything more than X% away. All drawing objects rebuild on the last bar so levels and labels stay current.
How to read it
Each timeframe has its own color (defaults: teal for TF1, amber for TF2, purple for TF3). The 50% and 61.8% lines are drawn thicker and more saturated — these are the classical reversal area — and the optional golden zone fill shades the band between them.
The 0% and 100% levels are the swing low and swing high themselves, drawn solid. Intermediate ratios are dashed. Extensions, when enabled, are dotted — visually marking them as projected targets rather than retracements.
When fib levels from different timeframes cluster around the same price, that's confluence — and tends to matter more than any single level on its own.
Inputs
Built-in alerts
A swing-confirmation alert is available for each timeframe and direction (six total):
Notes
The pivot lookback is the key knob. Small values (2–3) produce fast-moving fib ranges that retag often — useful for short-term retracement plays but visually busy. Larger values (5–10+) lock onto major structural swings that stay anchored for longer, which is closer to how most traders actually use Fibonacci.
Higher-timeframe pivots don't confirm until pivot lookback bars after the actual high or low. On a monthly timeframe with lookback 5, that's five months of delay. The reanchor lag is the price of getting confirmed, non-repainting levels.
When the retracement direction looks wrong — for example, price has clearly made a lower swing low but the indicator is still anchored to an older one — it usually means the new pivot hasn't confirmed yet on that timeframe. Drop down a timeframe or wait it out.
This is a structural tool, not a signal generator. It plots the classical retracement and extension grid across multiple horizons.
Five years of work on a trading system left me with dozens of indicators that ultimately didn't earn a place in the final build. They're not failures — they're tools that solved problems I no longer needed solved. So instead of shelving them, I'm publishing the majority of them open-source.
If you're a discretionary trader, take what's useful. If you're a systems builder, the source is yours to dissect, modify, and improve. The best return on five years of work is for it to keep working — for someone.
If you use this script — or part of it — in your own work, please credit the original with a link back to my profile.
Note: these indicators have been updated to Pine Script v6 — some manually, some with AI assistance.
Auto-anchored Fibonacci retracement levels drawn between the most recent confirmed swing high and swing low, replicated across up to three higher timeframes. As new pivots form on each timeframe, the levels reanchor automatically — no manual redrawing every time the swing range changes.
The point is to see Fibonacci structure across multiple horizons on a single chart, without juggling drawing tools.
How it works
For each of the three configured timeframes, the script runs a pivot detector inside request.security (with lookahead_off, so no future-data leak). The most recent confirmed swing high and swing low per timeframe are stored as the active anchors. Standard ratios — 0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, 100% — are computed between low and high, with optional extensions at 127.2%, 161.8%, 200%, and 261.8% beyond the 100% pivot.
A proximity filter compares each individual level to current close and hides anything more than X% away. All drawing objects rebuild on the last bar so levels and labels stay current.
How to read it
Each timeframe has its own color (defaults: teal for TF1, amber for TF2, purple for TF3). The 50% and 61.8% lines are drawn thicker and more saturated — these are the classical reversal area — and the optional golden zone fill shades the band between them.
The 0% and 100% levels are the swing low and swing high themselves, drawn solid. Intermediate ratios are dashed. Extensions, when enabled, are dotted — visually marking them as projected targets rather than retracements.
When fib levels from different timeframes cluster around the same price, that's confluence — and tends to matter more than any single level on its own.
Inputs
- Timeframes 1/2/3 — the three higher timeframes to source pivots from. Defaults: Daily, Weekly, Monthly. Choose timeframes higher than your chart timeframe.
- Pivot Lookback — bars required on each side to confirm a swing. Higher values detect only major swings and keep the anchors stable for longer. Default 5.
- Display toggles — turn each timeframe on or off independently.
- Golden Zone Fill — shade the 50%–61.8% band, the highest-probability reversal zone in classical Fibonacci analysis. Default on.
- Extensions — draw 127.2%, 161.8%, 200%, and 261.8% beyond the 100% pivot. Useful for projecting price targets once a full swing has been exceeded. Default off.
- Proximity filter — hide levels further than X% from current close. Default on, 10%.
- Colors — one per timeframe.
Built-in alerts
A swing-confirmation alert is available for each timeframe and direction (six total):
- New TF1 / TF2 / TF3 Swing High — fires when a new pivot high is confirmed and the Fibonacci range reanchors
- New TF1 / TF2 / TF3 Swing Low — fires when a new pivot low is confirmed and the Fibonacci range reanchors
Notes
The pivot lookback is the key knob. Small values (2–3) produce fast-moving fib ranges that retag often — useful for short-term retracement plays but visually busy. Larger values (5–10+) lock onto major structural swings that stay anchored for longer, which is closer to how most traders actually use Fibonacci.
Higher-timeframe pivots don't confirm until pivot lookback bars after the actual high or low. On a monthly timeframe with lookback 5, that's five months of delay. The reanchor lag is the price of getting confirmed, non-repainting levels.
When the retracement direction looks wrong — for example, price has clearly made a lower swing low but the indicator is still anchored to an older one — it usually means the new pivot hasn't confirmed yet on that timeframe. Drop down a timeframe or wait it out.
This is a structural tool, not a signal generator. It plots the classical retracement and extension grid across multiple horizons.
Five years of work on a trading system left me with dozens of indicators that ultimately didn't earn a place in the final build. They're not failures — they're tools that solved problems I no longer needed solved. So instead of shelving them, I'm publishing the majority of them open-source.
If you're a discretionary trader, take what's useful. If you're a systems builder, the source is yours to dissect, modify, and improve. The best return on five years of work is for it to keep working — for someone.
If you use this script — or part of it — in your own work, please credit the original with a link back to my profile.
Note: these indicators have been updated to Pine Script v6 — some manually, some with AI assistance.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน