PROTECTED SOURCE SCRIPT
Fibonacci extension overlay

A lightweight Fibonacci extension overlay that anchors to the most recent confirmed swing (two pivots) and plots one clean set of levels. Built for Pine v5 with no external libraries, it’s stable, fast, and easy to customize.
How it works
Detects pivots using ta.pivothigh/ta.pivotlow.
Uses the last two confirmed pivots (previous → latest) to define the swing.
Computes signed distance of the swing and draws extension levels anchored to the last pivot.
Lines extend to the right by default so levels stay visible as new bars print.
Inputs & options
Depth – sensitivity of pivot detection (smaller = more swings, larger = fewer).
Reverse – flip extension direction.
Extend Left / Right – control how far lines extend past the swing.
Show Levels / Show Prices – toggle text formatting on labels.
Labels Position – left or right of the swing.
Fill between levels (optional) – background fill between adjacent levels.
Background Transparency – opacity of any fills.
Tips
If nothing appears, reduce Depth or wait for two confirmed pivots on the current timeframe.
Works on any market and timeframe; lower TFs usually benefit from smaller Depth.
Because pivots are confirmed, plotted levels do not repaint once shown (they update only when a new pivot confirms).
Included levels
-0.65, -0.618, -0.382, -0.236, 0, 0.236, 0.382, 0.5, 0.618, 0.65, 0.786, 1, 1.272, 1.414, 1.618, 1.65, 2.618, 2.65, 3.618, 3.65, 4.236, 4.618
(Visibility, values, and colors are fully configurable.)
Notes
This script avoids duplicate drawings by updating persistent line/label objects instead of recreating them every bar.
Designed to be overlay-friendly and scale with the chart’s price axis.
How it works
Detects pivots using ta.pivothigh/ta.pivotlow.
Uses the last two confirmed pivots (previous → latest) to define the swing.
Computes signed distance of the swing and draws extension levels anchored to the last pivot.
Lines extend to the right by default so levels stay visible as new bars print.
Inputs & options
Depth – sensitivity of pivot detection (smaller = more swings, larger = fewer).
Reverse – flip extension direction.
Extend Left / Right – control how far lines extend past the swing.
Show Levels / Show Prices – toggle text formatting on labels.
Labels Position – left or right of the swing.
Fill between levels (optional) – background fill between adjacent levels.
Background Transparency – opacity of any fills.
Tips
If nothing appears, reduce Depth or wait for two confirmed pivots on the current timeframe.
Works on any market and timeframe; lower TFs usually benefit from smaller Depth.
Because pivots are confirmed, plotted levels do not repaint once shown (they update only when a new pivot confirms).
Included levels
-0.65, -0.618, -0.382, -0.236, 0, 0.236, 0.382, 0.5, 0.618, 0.65, 0.786, 1, 1.272, 1.414, 1.618, 1.65, 2.618, 2.65, 3.618, 3.65, 4.236, 4.618
(Visibility, values, and colors are fully configurable.)
Notes
This script avoids duplicate drawings by updating persistent line/label objects instead of recreating them every bar.
Designed to be overlay-friendly and scale with the chart’s price axis.
Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể tự do sử dụng tập lệnh mà không có bất kỳ hạn chế nào – tìm hiểu thêm tại đây.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể tự do sử dụng tập lệnh mà không có bất kỳ hạn chế nào – tìm hiểu thêm tại đây.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.