0% found this document useful (0 votes)
43 views5 pages

Auto Fibonacci Levels Script

automatic fib lev plottt

Uploaded by

vishveshjoshi22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views5 pages

Auto Fibonacci Levels Script

automatic fib lev plottt

Uploaded by

vishveshjoshi22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// This source code is subject to the terms of the Mozilla Public License 2.

0 at
[Link]
// © tv

//@version=4
study("auto fibo levels", overlay=true)
//------------------------------------------------------------------------------
extendType =input(false, title="Extend lines?") ? [Link] :
[Link]
show_price =input(true, title="show price?")
Reverse =input(false, title="Reverse Direction?")
//------------------------------------------------------------------------------

FPeriod = input(100, title="lookback length")


Fhigh = highest(FPeriod)
Flow = lowest(FPeriod)
SwingHigh = highestbars(high, FPeriod)
SwingLow = lowestbars(low, FPeriod)
downfib = Reverse ? SwingHigh > SwingLow : SwingHigh < SwingLow

X1_offset = downfib ? SwingHigh : SwingLow


X2_offset =15

bar_index_duration = time - time[1] // time


between bars

X1 = X1_offset * bar_index_duration //
starting level x position
X2 = X2_offset * bar_index_duration //
ending level x position
lbl_X2 = ((show_price ? 15 : 6) + X2_offset) * bar_index_duration //
label x position

F000 =downfib ? Flow : Fhigh


F236 =downfib ? (Fhigh-Flow) * 0.236 + Flow : Fhigh - (Fhigh-Flow) * 0.236
F382 =downfib ? (Fhigh-Flow) * 0.382 + Flow : Fhigh - (Fhigh-Flow) * 0.382
F500 =downfib ? (Fhigh-Flow) * 0.500 + Flow : Fhigh - (Fhigh-Flow) * 0.500
F618 =downfib ? (Fhigh-Flow) * 0.618 + Flow : Fhigh - (Fhigh-Flow) * 0.618
F786 =downfib ? (Fhigh-Flow) * 0.786 + Flow : Fhigh - (Fhigh-Flow) * 0.786
F100 =downfib ? Fhigh : Flow

F000_color =[Link]([Link],0)
F236_color =[Link]([Link],0)
F382_color =[Link]([Link],0)
F500_color =[Link]([Link],0)
F618_color =[Link]([Link],0)
F786_color =[Link]([Link],0)
F100_color =[Link]([Link],0)

F000_lbl =show_price ? "0% [" + tostring(F000) + " ]" : "0%"


F236_lbl =show_price ? "23.6% [" + tostring(F236) + " ]" : "23.6%"
F382_lbl =show_price ? "38.2% [" + tostring(F382) + " ]" : "38.2%"
F500_lbl =show_price ? "50% [" + tostring(F500) + " ]" : "50%"
F618_lbl =show_price ? "61.8% [" + tostring(F618) + " ]" : "61.8%"
F786_lbl =show_price ? "78.6% [" + tostring(F786) + " ]" : "78.6%"
F100_lbl =show_price ? "100% [" + tostring(F100) + " ]" : "100%"

//------------------------------------------------------------------------------
//Setup line & Label Appearance
line_style =line.style_solid
label_style =label.style_none
label_size =[Link]

//------------------------------------------------------------------------------
// 0 line
if true
ln = [Link](
x1 = time + X1,
y1 = F000,
x2 = time + X2,
y2 = F000,
xloc =xloc.bar_time,
extend =extendType,
color =F000_color,
style =line_style,
width =1
)
[Link](ln[1])
if true
lbl = [Link](
x =time + lbl_X2,
y =F000,
xloc =xloc.bar_time,
yloc =[Link],
text =F000_lbl,
color =F000_color,
textcolor =F000_color,
style =label_style,
size =label_size
)
[Link](lbl[1])

//------------------------------------------------------------------------------
//236 line
if true
ln = [Link](
x1 = time + X1,
y1 = F236,
x2 = time + X2,
y2 = F236,
xloc =xloc.bar_time,
extend =extendType,
color =F236_color,
style =line_style,
width =1
)
[Link](ln[1])
if true
lbl = [Link](
x =time + lbl_X2,
y =F236,
xloc =xloc.bar_time,
yloc =[Link],
text =F236_lbl,
color =F236_color,
textcolor =F236_color,
style =label_style,
size =label_size
)
[Link](lbl[1])

//------------------------------------------------------------------------------
// 382 line
if true
ln = [Link](
x1 = time + X1,
y1 = F382,
x2 = time + X2,
y2 = F382,
xloc =xloc.bar_time,
extend =extendType,
color =F382_color,
style =line_style,
width =1
)
[Link](ln[1])
if true
lbl = [Link](
x =time + lbl_X2,
y =F382,
xloc =xloc.bar_time,
yloc =[Link],
text =F382_lbl,
color =F382_color,
textcolor =F382_color,
style =label_style,
size =label_size
)
[Link](lbl[1])
//------------------------------------------------------------------------------
//500 line
if true
ln = [Link](
x1 = time + X1,
y1 = F500,
x2 = time + X2,
y2 = F500,
xloc =xloc.bar_time,
extend =extendType,
color =F500_color,
style =line_style,
width =1
)
[Link](ln[1])
if true
lbl = [Link](
x =time + lbl_X2,
y =F500,
xloc =xloc.bar_time,
yloc =[Link],
text =F500_lbl,
color =F500_color,
textcolor =F500_color,
style =label_style,
size =label_size
)
[Link](lbl[1])
//------------------------------------------------------------------------------
//618 line
if true
ln = [Link](
x1 = time + X1,
y1 = F618,
x2 = time + X2,
y2 = F618,
xloc =xloc.bar_time,
extend =extendType,
color =F618_color,
style =line_style,
width =1
)
[Link](ln[1])
if true
lbl = [Link](
x =time + lbl_X2,
y =F618,
xloc =xloc.bar_time,
yloc =[Link],
text =F618_lbl,
color =F618_color,
textcolor =F618_color,
style =label_style,
size =label_size
)
[Link](lbl[1])
//------------------------------------------------------------------------------

//786 line
if true
ln = [Link](
x1 = time + X1,
y1 = F786,
x2 = time + X2,
y2 = F786,
xloc =xloc.bar_time,
extend =extendType,
color =F786_color,
style =line_style,
width =1
)
[Link](ln[1])
if true
lbl = [Link](
x =time + lbl_X2,
y =F786,
xloc =xloc.bar_time,
yloc =[Link],
text =F786_lbl,
color =F786_color,
textcolor =F786_color,
style =label_style,
size =label_size
)
[Link](lbl[1])
//------------------------------------------------------------------------------
//100 line
if true
ln = [Link](
x1 = time + X1,
y1 = F100,
x2 = time + X2,
y2 = F100,
xloc =xloc.bar_time,
extend =extendType,
color =F100_color,
style =line_style,
width =1
)
[Link](ln[1])
if true
lbl = [Link](
x =time + lbl_X2,
y =F100,
xloc =xloc.bar_time,
yloc =[Link],
text =F100_lbl,
color =F100_color,
textcolor =F100_color,
style =label_style,
size =label_size
)
[Link](lbl[1])

You might also like