Untitled

 avatar
unknown
plain_text
4 months ago
3.4 kB
46
Indexable
//@version=5

indicator(title='Auto Fibonacci', overlay=true)
FPeriod = input(144, title='Fibo Period')
plotF1618 = input(title='Plot 1.618 Level?', defval=true)

Fhigh = ta.highest(FPeriod)
Flow = ta.lowest(FPeriod)
FH = ta.highestbars(high, FPeriod)
FL = ta.lowestbars(low, FPeriod)
downfibo = FH < FL

F0 = downfibo ? Flow : Fhigh
F236 = downfibo ? (Fhigh - Flow) * 0.236 + Flow : Fhigh - (Fhigh - Flow) * 0.236
F382 = downfibo ? (Fhigh - Flow) * 0.382 + Flow : Fhigh - (Fhigh - Flow) * 0.382
F500 = downfibo ? (Fhigh - Flow) * 0.500 + Flow : Fhigh - (Fhigh - Flow) * 0.500
F618 = downfibo ? (Fhigh - Flow) * 0.618 + Flow : Fhigh - (Fhigh - Flow) * 0.618
F786 = downfibo ? (Fhigh - Flow) * 0.786 + Flow : Fhigh - (Fhigh - Flow) * 0.786
F1000 = downfibo ? (Fhigh - Flow) * 1.000 + Flow : Fhigh - (Fhigh - Flow) * 1.000
F1618 = downfibo ? (Fhigh - Flow) * 1.618 + Flow : Fhigh - (Fhigh - Flow) * 1.618

Fcolor = downfibo ? #00cc00 : #E41019
Foffset = downfibo ? FH : FL

plot(F0 ,color=Fcolor, linewidth=4, trackprice=true, show_last=1, title='0')
plot(F236, color=Fcolor, linewidth=4, trackprice=true, show_last=1, title='0.236')
plot(F382, color=Fcolor, linewidth=4, trackprice=true, show_last=1, title='0.382')
plot(F500, color=Fcolor, linewidth=4, trackprice=true, show_last=1, title='0.5')
plot(F618, color=Fcolor, linewidth=4, trackprice=true, show_last=1, title='0.618')
plot(F786, color=Fcolor, linewidth=4, trackprice=true, show_last=1, title='0.786')
plot(F1000, color=Fcolor, linewidth=4, trackprice=true, show_last=1, title='1')
plot(plotF1618 and F1618 ? F1618 : na, color=Fcolor, linewidth=4, trackprice=true, show_last=1, title='1.618')

plotshape(F0, style=shape.labeldown, location=location.absolute,size = size.tiny, color=Fcolor, textcolor=color.new(#010513, 0), show_last=1, text='%0', offset=15)
plotshape(F236, style=shape.labeldown, location=location.absolute,size = size.tiny, color=Fcolor, textcolor=color.new(#010616, 0), show_last=1, text='%23.6', offset=15)
plotshape(F382, style=shape.labeldown, location=location.absolute,size = size.tiny, color=Fcolor, textcolor=color.new(#010614, 3), show_last=1, text='%38.2', offset=15)
plotshape(F500, style=shape.labeldown, location=location.absolute,size = size.tiny, color=Fcolor, textcolor=color.new(#010614, 0), show_last=1, text='%50', offset=15)
plotshape(F618, style=shape.labeldown, location=location.absolute,size = size.tiny, color=Fcolor, textcolor=color.new(#010716, 0), show_last=1, text='%61.8', offset=15)
plotshape(F786, style=shape.labeldown, location=location.absolute,size = size.tiny, color=Fcolor, textcolor=color.new(#02091f, 3), show_last=1, text='%78.6', offset=15)
plotshape(F1000, style=shape.labeldown, location=location.absolute,size = size.tiny, color=Fcolor, textcolor=color.new(#010716, 3), show_last=1, text='%100', offset=15)
plotshape(plotF1618 and F1618 ? F1618 : na, style=shape.labeldown, location=location.absolute, color=Fcolor, textcolor=color.new(#01081b, 0), show_last=1, text='%161.8', offset=15)

plotshape(Flow, style=shape.labelup, location=location.absolute, size=size.large, color=color.new(color.yellow, 0), textcolor=color.new(color.black, 0), show_last=1, text='Low', offset=FL)
plotshape(Fhigh, style=shape.labeldown, location=location.absolute, size=size.large, color=color.new(color.yellow, 0), textcolor=color.new(color.black, 0), show_last=1, text='High', offset=FH)




Editor is loading...
Leave a Comment