//@version=5
//Freemium indicators >> [Link]
indicator("AutoFibb", shorttitle="AutoFibb", overlay=true, max_labels_count=500,
max_lines_count=500, max_boxes_count=500, max_bars_back=500)
// Включение AutoFibo
AFBswitch = [Link](true, "AutoFibo", group='***Switch panel (Overlay
indicators)***', inline='S1')
// Группа настроек Auto Fibonacci
G_AutoFibo = '***Auto Fibonacci***'
// Входные параметры для уровней Fibonacci
FibHighLow = input(title='Higher High and Lower Low', defval=false,
group=G_AutoFibo, inline='AFB')
AFB0 = input(title='Level %0', defval=true, group=G_AutoFibo, inline='AFB')
AFB1 = input(title='Level %0.236', defval=true, group=G_AutoFibo, inline='AFB1')
AFB2 = input(title='Level %0.382', defval=true, group=G_AutoFibo, inline='AFB1')
AFB3 = input(title='Level %0.5', defval=true, group=G_AutoFibo, inline='AFB1')
AFB4 = input(title='Level %0.618', defval=true, group=G_AutoFibo, inline='AFB2')
AFB5 = input(title='Level %0.786', defval=true, group=G_AutoFibo, inline='AFB2')
AFB6 = input(title='Level %1', defval=true, group=G_AutoFibo, inline='AFB2')
AFB7 = input(title='Level %1.618', defval=false, group=G_AutoFibo, inline='AFB3')
AFB8 = input(title='Level %2', defval=false, group=G_AutoFibo, inline='AFB3')
AFB9 = input(title='Level %2.618', defval=false, group=G_AutoFibo, inline='AFB3')
AFB10 = input(title='Level %-0.618', defval=false, group=G_AutoFibo, inline='AFB4')
AFB11 = input(title='Level %-161.8', defval=false, group=G_AutoFibo, inline='AFB4')
AFB12 = input(title='Level %-2', defval=false, group=G_AutoFibo, inline='AFB4')
AFB13 = input(title='Level %-261.8', defval=false, group=G_AutoFibo, inline='AFB4')
FPeriod = input(500, title='Fibo Period', group=G_AutoFibo)
// Расчет высшего и низшего значений за период
Fhigh = [Link](FPeriod)
Flow = [Link](FPeriod)
FH = [Link](high, FPeriod)
FL = [Link](low, FPeriod)
AutoFibo = FH < FL
// Расчет уровней Fibonacci
F0 = AutoFibo ? Flow : Fhigh
F236 = AutoFibo ? (Fhigh - Flow) * 0.236 + Flow : Fhigh - (Fhigh - Flow) * 0.236
F382 = AutoFibo ? (Fhigh - Flow) * 0.382 + Flow : Fhigh - (Fhigh - Flow) * 0.382
F500 = AutoFibo ? (Fhigh - Flow) * 0.500 + Flow : Fhigh - (Fhigh - Flow) * 0.500
F618 = AutoFibo ? (Fhigh - Flow) * 0.618 + Flow : Fhigh - (Fhigh - Flow) * 0.618
F786 = AutoFibo ? (Fhigh - Flow) * 0.786 + Flow : Fhigh - (Fhigh - Flow) * 0.786
F1000 = AutoFibo ? (Fhigh - Flow) * 1.000 + Flow : Fhigh - (Fhigh - Flow) * 1.000
F1618 = AutoFibo ? (Fhigh - Flow) * 1.618 + Flow : Fhigh - (Fhigh - Flow) * 1.618
F2000 = AutoFibo ? (Fhigh - Flow) * 2.000 + Flow : Fhigh - (Fhigh - Flow) * 2.000
F2618 = AutoFibo ? (Fhigh - Flow) * 2.618 + Flow : Fhigh - (Fhigh - Flow) * 2.618
FNeg618 = AutoFibo ? Flow - (Fhigh - Flow) * 0.618 : Fhigh + (Fhigh - Flow) * 0.618
FNeg1618 = AutoFibo ? Flow - (Fhigh - Flow) * 1.618 : Fhigh + (Fhigh - Flow) *
1.618
FNeg2000 = AutoFibo ? Flow - (Fhigh - Flow) * 2.000 : Fhigh + (Fhigh - Flow) *
2.000
FNeg2618 = AutoFibo ? Flow - (Fhigh - Flow) * 2.618 : Fhigh + (Fhigh - Flow) *
2.618
// Цвета уровней Fibonacci
Fcolor = #aacf92
FBcolor = #5a9afb
FUpDoColor = #f1680c
NFColor = #f76ad8e0
OFColor = #00ff0d
// Отображение уровней Fibonacci
plot(AFB0 and AFBswitch ? F0 : na, color=Fcolor, linewidth=1, trackprice=true,
show_last=1, title='0')
plot(AFB1 and AFBswitch ? F236 : na, color=Fcolor, linewidth=1, trackprice=true,
show_last=1, title='0.236')
plot(AFB2 and AFBswitch ? F382 : na, color=Fcolor, linewidth=1, trackprice=true,
show_last=1, title='0.382')
plot(AFB3 and AFBswitch ? F500 : na, color=NFColor, linewidth=1, trackprice=true,
show_last=1, title='0.5')
plot(AFB4 and AFBswitch ? F618 : na, color=FBcolor, linewidth=1, trackprice=true,
show_last=1, title='0.618')
plot(AFB5 and AFBswitch ? F786 : na, color=Fcolor, linewidth=1, trackprice=true,
show_last=1, title='0.786')
plot(AFB6 and AFBswitch ? F1000 : na, color=OFColor, linewidth=1, trackprice=true,
show_last=1, title='1')
plot(AFB7 and AFBswitch ? F1618 : na, color=Fcolor, linewidth=1, trackprice=true,
show_last=1, title='1.618')
plot(AFB8 and AFBswitch ? F2000 : na, color=Fcolor, linewidth=1, trackprice=true,
show_last=1, title='2')
plot(AFB9 and AFBswitch ? F2618 : na, color=Fcolor, linewidth=1, trackprice=true,
show_last=1, title='2.618')
plot(AFB10 and AFBswitch ? FNeg618 : na, color=Fcolor, linewidth=1,
trackprice=true, show_last=1, title='-0.618')
plot(AFB11 and AFBswitch ? FNeg1618 : na, color=Fcolor, linewidth=1,
trackprice=true, show_last=1, title='-1.618')
plot(AFB12 and AFBswitch ? FNeg2000 : na, color=Fcolor, linewidth=1,
trackprice=true, show_last=1, title='-2')
plot(AFB13 and AFBswitch ? FNeg2618 : na, color=Fcolor, linewidth=1,
trackprice=true, show_last=1, title='-2.618')
// Отображение уровней Fibonacci в виде фигур
plotshape(AFB0 and AFBswitch ? F0 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#ff0000, 12),
show_last=1, text='%0', offset=15)
plotshape(AFB1 and AFBswitch ? F236 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#aacf92, 12),
show_last=1, text='%0.236', offset=15)
plotshape(AFB2 and AFBswitch ? F382 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#aacf92, 12),
show_last=1, text='%0.382', offset=15)
plotshape(AFB3 and AFBswitch ? F500 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=#f76ad8e0, show_last=1,
text='%0.5', offset=15)
plotshape(AFB4 and AFBswitch ? F618 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#5a9afb, 12),
show_last=1, text='%0.618', offset=15)
plotshape(AFB5 and AFBswitch ? F786 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#aacf92, 12),
show_last=1, text='%0.786', offset=15)
plotshape(AFB6 and AFBswitch ? F1000 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#00ff0d, 12),
show_last=1, text='%1', offset=15)
plotshape(AFB7 and AFBswitch ? F1618 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#aacf92, 12),
show_last=1, text='%1.618', offset=15)
plotshape(AFB8 and AFBswitch ? F2000 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#aacf92, 12),
show_last=1, text='%2', offset=15)
plotshape(AFB9 and AFBswitch ? F2618 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#aacf92, 12),
show_last=1, text='%2.618', offset=15)
plotshape(AFB10 and AFBswitch ? FNeg618 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#aacf92, 12),
show_last=1, text='%-0.618', offset=15)
plotshape(AFB11 and AFBswitch ? FNeg1618 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#aacf92, 12),
show_last=1, text='%-1.618', offset=15)
plotshape(AFB12 and AFBswitch ? FNeg2000 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#aacf92, 12),
show_last=1, text='%-2', offset=15)
plotshape(AFB13 and AFBswitch ? FNeg2618 : na, style=[Link],
location=[Link], color=#ffffff00, textcolor=[Link](#aacf92, 12),
show_last=1, text='%-2.618', offset=15)
// Отображение высшего и низшего значений за период
plotshape(FibHighLow and AFBswitch ? Flow : na, style=[Link],
location=[Link], size=[Link], color=[Link](#ff6600, 0),
textcolor=[Link]([Link], 0), show_last=1, text='Low', offset=FL)
plotshape(FibHighLow and AFBswitch ? Fhigh : na, style=[Link],
location=[Link], size=[Link], color=[Link](#ff6600, 0),
textcolor=[Link]([Link], 0), show_last=1, text='High', offset=FH)