Zigzag Fib Golden Zone Ualgo
Zigzag Fib Golden Zone Ualgo
Zigzag Fib Golden Zone Ualgo
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © UAlgo
indicator("Zigzag Fibonacci Golden Zone [UAlgo]",overlay=true,max_bars_back=5000)
upper = ta.highest(srcUpper,length)
lower = ta.lowest(srcLower,length)
os := srcUpper[length] >= upper ? 0 : srcLower[length] <= lower ? 1 : os[1]
pl = os == 1 and os[1] != 1
ph = os == 0 and os[1] != 0
pl_n = ta.valuewhen(pl,bar_index,0)
ph_n = ta.valuewhen(ph,bar_index,0)
len = math.abs(pl_n - ph_n)
if pl
valbtm := low[length]
line.new(bar_index[len+length],valtop,bar_index[length],low[length],color=zzColor)
if not na(draw_bottom)
line.delete(draw_bottom)
line.delete(draw_500)
line.delete(draw_618)
line.delete(draw_786)
label.delete(draw_goldenZone)
if array.size(btm_points) == 0
array.push(btm_points,valbtm)
valBottomDraw := array.get(btm_points, 0)
draw_bottom := line.new(bar_index[length], valBottomDraw, bar_index,
valBottomDraw, color=color.purple,extend = extend.right)
draw_500 := line.new(bar_index[length], (valTopDraw+valBottomDraw)/2,
bar_index, (valTopDraw+valBottomDraw)/2, color=color.rgb(82, 255, 226),extend =
extend.right,style = line.style_solid)
draw_618 := line.new(bar_index[length], (valTopDraw-
valBottomDraw)*0.382+valBottomDraw, bar_index, (valTopDraw-
valBottomDraw)*0.382+valBottomDraw, color=color.yellow,extend = extend.right,style
= line.style_solid)
draw_786 := line.new(bar_index[length], (valTopDraw-
valBottomDraw)*0.236+valBottomDraw, bar_index, (valTopDraw-
valBottomDraw)*0.236+valBottomDraw, color=color.yellow,extend = extend.right,style
= line.style_solid)
else if array.size(btm_points) > 0
array.shift(btm_points)
array.push(btm_points,valbtm)
valBottomDraw := array.get(btm_points, 0)
draw_bottom := line.new(bar_index[length], valBottomDraw, bar_index,
valBottomDraw, color=color.purple,extend = extend.right)
draw_500 := line.new(bar_index[length], (valTopDraw+valBottomDraw)/2,
bar_index, (valTopDraw+valBottomDraw)/2, color=color.rgb(82, 255, 226),extend =
extend.right,style = line.style_solid)
draw_618 := line.new(bar_index[length], (valTopDraw-
valBottomDraw)*0.382+valBottomDraw, bar_index, (valTopDraw-
valBottomDraw)*0.382+valBottomDraw, color=color.yellow,extend = extend.right,style
= line.style_solid)
draw_786 := line.new(bar_index[length], (valTopDraw-
valBottomDraw)*0.236+valBottomDraw, bar_index, (valTopDraw-
valBottomDraw)*0.236+valBottomDraw, color=color.yellow,extend = extend.right,style
= line.style_solid)
if showPrices
label.new(bar_index[length], low[length], text=str.tostring(low[length]),
color=color.new(#00000000, 0), style=label.style_label_up, textcolor=zzBotColor,
textalign=text.align_left, size=size.small)
draw_goldenZone := label.new(bar_index, (valTopDraw-
valBottomDraw)*0.236+valBottomDraw, text="Golden Zone", color=color.new(#000000,
100), style=label.style_label_up, textcolor=color.yellow,
textalign=text.align_left, size=size.small)
if ph
valtop := high[length]
line.new(bar_index[len+length],valbtm,bar_index[length],high[length],color=zzColor)
if not na(draw_top)
line.delete(draw_top)
line.delete(draw_500)
line.delete(draw_618)
line.delete(draw_786)
label.delete(draw_goldenZone)
if array.size(top_points) == 0
array.push(top_points,valtop)
valTopDraw := array.get(top_points, 0)
draw_top := line.new(bar_index[length], valTopDraw, bar_index, valTopDraw,
color=color.purple,extend = extend.right)
draw_500 := line.new(bar_index[length], (valTopDraw+valBottomDraw)/2,
bar_index, (valTopDraw+valBottomDraw)/2, color=color.rgb(82, 255, 226),extend =
extend.right,style = line.style_solid,width = 5)
draw_618 := line.new(bar_index[length], (valTopDraw-
valBottomDraw)*0.618+valBottomDraw, bar_index, (valTopDraw-
valBottomDraw)*0.618+valBottomDraw, color=color.yellow,extend = extend.right,style
= line.style_solid)
draw_786 := line.new(bar_index[length], (valTopDraw-
valBottomDraw)*0.786+valBottomDraw, bar_index, (valTopDraw-
valBottomDraw)*0.786+valBottomDraw, color=color.yellow,extend = extend.right,style
= line.style_solid)
else if array.size(top_points) > 0
array.shift(top_points)
array.push(top_points,valtop)
valTopDraw := array.get(top_points, 0)
draw_top := line.new(bar_index[length], valTopDraw, bar_index, valTopDraw,
color=color.purple,extend = extend.right)
draw_500 := line.new(bar_index[length], (valTopDraw+valBottomDraw)/2,
bar_index, (valTopDraw+valBottomDraw)/2, color=color.rgb(82, 255, 226),extend =
extend.right,style = line.style_solid)
draw_618 := line.new(bar_index[length], (valTopDraw-
valBottomDraw)*0.618+valBottomDraw, bar_index, (valTopDraw-
valBottomDraw)*0.618+valBottomDraw, color=color.yellow,extend = extend.right,style
= line.style_solid)
draw_786 := line.new(bar_index[length], (valTopDraw-
valBottomDraw)*0.786+valBottomDraw, bar_index, (valTopDraw-
valBottomDraw)*0.786+valBottomDraw, color=color.yellow,extend = extend.right,style
= line.style_solid)
if showPrices
label.new(bar_index[length],high[length],str.tostring(high[length]),color=#00000000
,style=label.style_label_down,textcolor=zzTopColor,textalign=text.align_left,size=s
ize.small)
draw_goldenZone := label.new(bar_index, valBottomDraw + (valTopDraw-
valBottomDraw), text="Golden Zone", color=color.new(#000000, 100),
style=label.style_label_up, textcolor=color.yellow, textalign=text.align_left,
size=size.small)
else
sellSignal := false