TradingView
Maga3
Dec 17, 2016 4:21 PM

[M] MTF Fibonacci levels 

Australian Dollar/U.S. DollarFXCM

Description

Automatic drawing Fibonacci levels for such lazy like me =)
Comments
Maga3
My indicator simply draws the fibo levels from high to low, I do not know why people like it and ask for its code. But if you need it, then take it)


//@version=2

study(title='[M] MTF Fibonacci levels', shorttitle='Fib', overlay=true)
TimeFrame = input('1D',type=string,title="Timeframe" )
fiblength=input(1,minval=1,title="Length")

zeroSrc = close > open ? high : low

Z_000 = security(tickerid, TimeFrame, sum(zeroSrc,fiblength)/fiblength)
H_100 = security(tickerid, TimeFrame, highest(high,fiblength))
L_100 = security(tickerid, TimeFrame, lowest(low,fiblength))

H_RANGE = H_100-Z_000
L_RANGE = Z_000-L_100

H_764 = H_100 - H_RANGE * 0.236
H_618 = H_100 - H_RANGE * 0.382
H_500 = H_100 - H_RANGE * 0.500
H_382 = H_100 - H_RANGE * 0.618
H_236 = H_100 - H_RANGE * 0.764

L_764 = L_100 + L_RANGE * 0.236
L_618 = L_100 + L_RANGE * 0.382
L_500 = L_100 + L_RANGE * 0.500
L_382 = L_100 + L_RANGE * 0.618
L_236 = L_100 + L_RANGE * 0.764

h100=plot( series=change(H_100)!=0?na:H_100, title="100", color=black, transp=0, linewidth=2,style=linebr)
h764=plot( series=change(H_764)!=0?na:H_764, title="76.4", color=yellow, transp=0,style=linebr, linewidth=2)
h618=plot( series=change(H_618)!=0?na:H_618, title="61.8", color=blue, transp=0,style=linebr, linewidth=2)
h500=plot( series=change(H_500)!=0?na:H_500, title="50.0", color=lime, transp=0,style=linebr, linewidth=2)
h382=plot( series=change(H_382)!=0?na:H_382, title="38.2", color=green, transp=0,style=linebr, linewidth=2)
h236=plot( series=change(H_236)!=0?na:H_236, title="23.6", color=red, transp=0,style=linebr, linewidth=2)
l236=plot( series=change(L_236)!=0?na:L_236, title="23.6", color=red, transp=0,style=linebr, linewidth=2)
l382=plot( series=change(L_382)!=0?na:L_382, title="38.2", color=green, transp=0,style=linebr, linewidth=2)
l500=plot( series=change(L_100)!=0?na:L_500, title="50.0", color=lime, transp=0,style=linebr, linewidth=2)
l618=plot( series=change(L_618)!=0?na:L_618, title="61.8", color=blue, transp=0,style=linebr, linewidth=2)
l764=plot( series=change(L_764)!=0?na:L_764, title="76.4", color=yellow, transp=0,style=linebr, linewidth=2)
l100=plot( series=change(L_100)!=0?na:L_100, title="100", color=black, transp=0, linewidth=2,style=linebr)
zero=plot( series=change(Z_000)!=0?na:Z_000, title="0.00", color=black, transp=0, linewidth=2,style=linebr)
slimer0
@Maga3, Great job. How can i convert it to @version4?
Planorcu
@Maga3, thank you
gkntr
@Maga3, Thanks Sir. You are the best. But I've noticed in your script
"zeroSrc = close > open ? high : low" part should be like below
"zeroSrc = open > close ? high : low"
right ?
davesarge
Great indicator. Just curious why there are two of each level? And I notice the 50% level sometimes is also the high/low of the period. Is that to show the direction? And when does it change colour? On close of candle?
Hroon
@davesarge, how to use this Fibonacci level?
janor123
How do you create the labels on the right (Fib:61.8, Fib:50.0, etc.)??
JayP2577
Does this repaint?
Barbaros_Tosun
I think it repaints, did you experience whether it does so?
JayP2577
@Barbaros_Tosun, yes it repaints, however you can still use it as a guide line
More