# Auto Fibonacci Retracament Levels by KIVANÇ fr3762

This indicator/tool (Auto Fibo) draws Fibonacci Retracement Levels automatically on qny chart.
The algorithm of the Indicator Plots the extreme points and puts the retracement levels in order by itself with 100% sensitivity.
The key point is that to arrange the length of the "lookback bars" to arrange the correct extreme points.
Like the other auto plotting tools, the levels can change when the time frame of the chart changes, in contrast with manually drawn Fibo levels.

In technical analysis , a Fibonacci retracement is created by taking two extreme points (usually a major peak and trough) on a stock chart and dividing the vertical distance by the key Fibonacci ratios of 23.6%, 38.2%, 50%, 61.8% and 100%.

1.618
2.618 and
3.618 levels are hidden for the purpose of not filling the chart with lots of lines...

users may choose to open those hidden levels by checking the related boxes in the inputs section of the indicator settings ...

TURKISH:
-İndikatöre 1 tane değiştirilebilir Fibonacci Seviyesi eklendi

1.618
2.618 ve
3.618 seviyeleri grafiği çizgilerle doldurmamak adına gizlendi...

kullanıcılar gizlenen bu seviyeleri indikatör ayarlarına girdiklerinde ilgili kutucukları işaretleyerek açabilirler
Sürüm Notları: updated to V5

Here's the source code for developers.

//@version=5
indicator('Auto Fibo', overlay=true)
len = input(144, 'Auto Fibo Length')

hl1272a = input(1.272, 'Adjustable Fibo Level')

AFL = input(false, title='Show Adjustable Fibo Level?')
AFL1 = input(false, title='Show 1.618 Fibo Level?')
AFL2 = input(false, title='Show 2.618 Fibo Level?')
AFL3 = input(false, title='Show 3.618 Fibo Level?')

h1 = ta.highest(high, len)
l1 = ta.lowest(low, len)
fark = h1 - l1

hl236 = l1 + fark * 0.236
hl382 = l1 + fark * 0.382
hl500 = l1 + fark * 0.5
hl618 = l1 + fark * 0.618
hl786 = l1 + fark * 0.786
hl1272 = l1 + fark * hl1272a
hl1618 = l1 + fark * 1.618
hl2618 = l1 + fark * 2.618
hl3618 = l1 + fark * 3.618

lh236 = h1 - fark * 0.236
lh382 = h1 - fark * 0.382
lh500 = h1 - fark * 0.5
lh618 = h1 - fark * 0.618
lh786 = h1 - fark * 0.786
lh1272 = h1 - fark * hl1272a
lh1618 = h1 - fark * 1.618
lh2618 = h1 - fark * 2.618
lh3618 = h1 - fark * 3.618

hbars = -ta.highestbars(high, len)
lbars = -ta.lowestbars(low, len)

f236 = hbars > lbars ? hl236 : lh236
f382 = hbars > lbars ? hl382 : lh382
f500 = hbars > lbars ? hl500 : lh500
f618 = hbars > lbars ? hl618 : lh618
f786 = hbars > lbars ? hl786 : lh786
f1272 = hbars > lbars ? hl1272 : lh1272
f1618 = hbars > lbars ? hl1618 : lh1618
f2618 = hbars > lbars ? hl2618 : lh2618
f3618 = hbars > lbars ? hl3618 : lh3618

plot(l1, trackprice=true, offset=-9999, color=color.new(#4B0082, 0), linewidth=3)
plot(h1, trackprice=true, offset=-9999, color=color.new(#4B0082, 0), linewidth=3)

plot(f236, trackprice=true, offset=-9999, color=color.new(color.black, 0), title='0.236')
plot(f382, trackprice=true, offset=-9999, color=color.new(color.blue, 0), linewidth=1, title='0.382')
plot(f500, trackprice=true, offset=-9999, color=color.new(color.gray, 0), linewidth=1, title='0.5')
plot(f618, trackprice=true, offset=-9999, color=color.new(#800000, 0), linewidth=2, title='0.618')
plot(f786, trackprice=true, offset=-9999, color=color.new(color.black, 0), title='0.786')
plot(AFL and f1272 ? f1272 : na, trackprice=true, offset=-9999, color=color.new(color.red, 0), linewidth=2, title='1.272')
plot(AFL1 and f1618 ? f1618 : na, trackprice=true, offset=-9999, color=color.new(color.red, 0), linewidth=2, title='1.618')
plot(AFL2 and f2618 ? f2618 : na, trackprice=true, offset=-9999, color=color.new(color.red, 0), linewidth=2, title='2.618')
plot(AFL3 and f3618 ? f3618 : na, trackprice=true, offset=-9999, color=color.new(color.red, 0), linewidth=2, title='3.618')