PROTECTED SOURCE SCRIPT

Fibonacci extension overlay

101
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.

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。