Indicator · Pine Script v5 · On the chart

Fibonacci Levels MTF

by theonetrade· code credited to LonesomeTheBlue

Fibonacci Levels MTF is an overlay indicator that projects multi-timeframe Fibonacci retracement and extension levels onto the main price chart.

View on GitHub

GitHub stars34on the repository
Pine versionv5runs as is
Lines of code120
Settings34inputs
LicenceMIT
Last update2 weeks ago8 Nov 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

120 lines of Pine Script v5 from assets/indicator/bit-exact/fibonacci_levels_mtf_6BL47X8Q.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

fibonacci_levels_mtf_6BL47X8Q.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LonesomeTheBlue

//@version=5
indicator("Fibonacci levels MTF", overlay = true)
timeframe = input.timeframe(defval = "D", title = "Higher Time Frame")
currentlast = input.string(defval = "Last", title = "Current or Last HTF Candle", options = ["Current", "Last"])

showfibolabels = input.bool(defval = true, title = "Price Labels")

showhtfcandle = input.bool(defval = false, title = "Show HTF Candles", inline ="candle")
upcol = input.color(defval = color.rgb(0, 255, 0, 75), title = "", inline ="candle")
downcol = input.color(defval = color.rgb(255, 0, 0, 75), title = "", inline ="candle")
wickcol = input.color(defval = color.new(color.gray, 75), title = "", inline ="candle")
enable0 = input.bool(defval = true, title = "Level 0", inline = "0", group = "Fibonacci Levels")
level0 = input.float(defval = 0.000, title = "", inline = "0", group = "Fibonacci Levels")
color0 = input.color(defval = color.blue, title = "", inline = "0", group = "Fibonacci Levels")
enable1 = input.bool(defval = true, title = "Level 1", inline = "1", group = "Fibonacci Levels")
level1 = input.float(defval = 0.236, title = "", inline = "1", group = "Fibonacci Levels")
color1 = input.color(defval = color.lime, title = "", inline = "1", group = "Fibonacci Levels")
enable2 = input.bool(defval = true, title = "Level 2", inline = "2", group = "Fibonacci Levels")
level2 = input.float(defval = 0.382, title = "", inline = "2", group = "Fibonacci Levels")
color2 = input.color(defval = color.red, title = "", inline = "2", group = "Fibonacci Levels")
enable3 = input.bool(defval = true, title = "Level 3", inline = "3", group = "Fibonacci Levels")
level3 = input.float(defval = 0.500, title = "", inline = "3", group = "Fibonacci Levels")
color3 = input.color(defval = color.orange, title = "", inline = "3", group = "Fibonacci Levels")
enable4 = input.bool(defval = true, title = "Level 4", inline = "4", group = "Fibonacci Levels")
level4 = input.float(defval = 0.618, title = "", inline = "4", group = "Fibonacci Levels")
color4 = input.color(defval = color.teal, title = "", inline = "4", group = "Fibonacci Levels")
enable5 = input.bool(defval = true, title = "Level 5", inline = "5", group = "Fibonacci Levels")
level5 = input.float(defval = 0.786, title = "", inline = "5", group = "Fibonacci Levels")
color5 = input.color(defval = color.navy, title = "", inline = "5", group = "Fibonacci Levels")

enable100 = input.bool(defval = true, title = "Level 6", inline = "100", group = "Fibonacci Levels")
level100 = input.float(defval = 1, title = "", inline = "100", group = "Fibonacci Levels")
color100 = input.color(defval = color.blue, title = "", inline = "100", group = "Fibonacci Levels")

enable6 = input.bool(defval = false, title = "Level 7", inline = "6", group = "Fibonacci Levels")
level6 = input.float(defval = -0.382, title = "", inline = "6", group = "Fibonacci Levels")
color6 = input.color(defval = color.gray, title = "", inline = "6", group = "Fibonacci Levels")

enable7 = input.bool(defval = false, title = "Level 8", inline = "7", group = "Fibonacci Levels")
level7 = input.float(defval = 1.236, title = "", inline = "7", group = "Fibonacci Levels")
color7 = input.color(defval = color.gray, title = "", inline = "7", group = "Fibonacci Levels")



// htf candle
newbar = ta.change(time(timeframe)) != 0 
var float htfhigh = high
var float htflow = low
var float htfopen = open
float htfclose = close
var counter = 0
if newbar
    htfhigh := high
    htflow := low
    htfopen := open
    counter := 0
else
    htfhigh := math.max(htfhigh, high)
    htflow := math.min(htflow, low)
    counter += 1
if showhtfcandle
    var candle = array.new_box(3, na)
    if not newbar
        for x = 0 to 2
            box.delete(array.get(candle, x))
    array.set(candle, 0, box.new(bar_index - counter, math.max(htfopen, htfclose), bar_index, math.min(htfopen, htfclose), border_width = 0, bgcolor = htfclose >= htfopen ? upcol : downcol))
    array.set(candle, 1, box.new(bar_index - counter, htfhigh, bar_index, math.max(htfopen, htfclose), border_width = 0, bgcolor = wickcol))
    array.set(candle, 2, box.new(bar_index - counter, math.min(htfopen, htfclose), bar_index, htflow, border_width = 0, bgcolor = wickcol))

var float open_ = na
var float high_ = na
var float low_ = na
var float close_ = na
if currentlast == "Last" and newbar
    open_ := htfopen[1]
    high_ := htfhigh[1]
    low_ := htflow[1]
    close_ := htfclose[1]
else if currentlast == "Current"
    open_ := htfopen
    high_ := htfhigh
    low_ := htflow
    close_ := htfclose
    
var enabled = array.from(enable100, enable7, enable6, enable5, enable4, enable3, enable2, enable1, enable0)
var levels = array.from(level100, level7, level6, level5, level4, level3, level2, level1, level0)
var colors = array.from(color100, color7, color7, color5, color4, color3, color2, color1, color0)
mlevels = array.new_float(9, na)
if not newbar 
    for x = 0 to array.size(levels) - 1
        array.set(mlevels, x, array.get(enabled, x) ? (close_ >= open_ ? high_ - (high_ - low_) * array.get(levels, x) : low_ + (high_ - low_) * array.get(levels, x)) : na)

// fibonacci levels
plot(array.get(mlevels, 0), color = array.get(colors, 0), style=plot.style_linebr)
plot(array.get(mlevels, 1), color = array.get(colors, 1), style=plot.style_linebr)
plot(array.get(mlevels, 2), color = array.get(colors, 2), style=plot.style_linebr)
plot(array.get(mlevels, 3), color = array.get(colors, 3), style=plot.style_linebr)
plot(array.get(mlevels, 4), color = array.get(colors, 4), style=plot.style_linebr)
plot(array.get(mlevels, 5), color = array.get(colors, 5), style=plot.style_linebr)
plot(array.get(mlevels, 6), color = array.get(colors, 6), style=plot.style_linebr)
plot(array.get(mlevels, 7), color = array.get(colors, 7), style=plot.style_linebr)
plot(array.get(mlevels, 8), color = array.get(colors, 8), style=plot.style_linebr)

if barstate.islast and showfibolabels
    var flabels = array.new_label(0)
    for x = 0 to (array.size(flabels) > 0 ? array.size(flabels) - 1 : na)
        label.delete(array.pop(flabels))
    float mid = (high_ + low_) / 2
    for x = 0 to (array.size(enabled) > 0 ? array.size(enabled) - 1 : na)
        if array.get(enabled, x)
            level = array.get(mlevels, x)
            stl = level > mid ? label.style_label_lower_left : level < mid ? label.style_label_upper_left : label.style_label_left
            array.push(flabels, label.new(bar_index + 1, level, 
                                          text = str.tostring(math.round(array.get(levels, x), 3)) + " (" + str.tostring(math.round_to_mintick(level)) + ")", 
                                          color = array.get(colors, x), 
                                          textcolor = color.white, 
                                          style = stl))

Overview

Fibonacci Levels MTF calculates price boundaries from a user-specified higher time frame, using either the active developing candle or the prior completed candle. Users can enable and customize individual ratio levels, display price labels for each active line, and optionally overlay higher timeframe candle bodies directly onto lower timeframe charts.

Details

Published by

theonetrade on GitHub

Code credit

LonesomeTheBlue, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Higher Time FrametimeframeDtimeframe
Current or Last HTF CandlestringLastcurrentlast
Price Labelsbooltrueshowfibolabels
Show HTF Candlesboolfalseshowhtfcandle
upcolcolorcolor.rgb(0, 255, 0, 75)upcol
downcolcolorcolor.rgb(255, 0, 0, 75)downcol
wickcolcolorcolor.new(color.gray, 75)wickcol
Level 0booltrueenable0
level0float0.000level0
color0colorcolor.bluecolor0
Level 1booltrueenable1
level1float0.236level1
Show all 34 settings
SettingTypeDefaultVariable
color1colorcolor.limecolor1
Level 2booltrueenable2
level2float0.382level2
color2colorcolor.redcolor2
Level 3booltrueenable3
level3float0.500level3
color3colorcolor.orangecolor3
Level 4booltrueenable4
level4float0.618level4
color4colorcolor.tealcolor4
Level 5booltrueenable5
level5float0.786level5
color5colorcolor.navycolor5
Level 6booltrueenable100
level100float1level100
color100colorcolor.bluecolor100
Level 7boolfalseenable6
level6float-0.382level6
color6colorcolor.graycolor6
Level 8boolfalseenable7
level7float1.236level7
color7colorcolor.graycolor7
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

947 stars

Moving Average Channel plots separate simple moving averages for upper and lower bands on the price chart. It fills the space between bands with semi-transparent color and colors bars green above the upper band, red below the lower band, or gray in between. Us

Indicator v4 Moving averagesSupport & resistance
Updated 5 weeks ago · GPL-3.0 GitHub repository of Moving Average Channel

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows
368 stars

This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale

Indicator v5 Support & resistanceScreeners & dashboards
Updated 3 months ago · None stated GitHub repository of Multi Alert Long/Short [Alorse]

This overlay indicator draws a fixed-range volume profile on the price chart, splitting traded activity into up and down volume at each price level. It also plots a sentiment profile, a developing point of control, and value-area high and low around a configur

Indicator v5 VolumeSupport & resistance
Updated 8 days ago · MIT GitHub repository of Volume Profile and Indicator by DGT

Swing labels

by tradoor-terminal
320 stars

Calculates swing highs and swing lows on the price chart using pivot high and pivot low detection over a specified length. It places labels above pivot highs and below pivot lows to highlight key structural swing points. The indicator measures and displays the

Indicator v6 Support & resistanceTrend
Updated 3 days ago · AGPL-3.0 GitHub repository of Swing labels

BZ-tracker

by Allen1212
302 stars

The BZ-tracker indicator marks ARK Invest buy and sell transactions on stock charts with labels. It plots green labels for purchases and red labels for sales, each annotated with a multiplier such as X1 or X2 to show the number of ARK ETFs trading the stock on

Indicator v4 Support & resistanceScreeners & dashboards
Updated 3 years ago · None stated GitHub repository of BZ-tracker

More Support & resistance scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers