gann fib lines
gann fib lines
if newbar
if not na(prev_time)
line.new(prev_time, decp, tim, decp, xloc.bar_time, color=#030713,
width=wi)
if pslab
label.new(prev_time, decp, text="Pivot :" + str.tostring(decp,
"#.####") + " " + tfLabel,style=label.style_label_right, color =color.white,
textcolor=#02091c, size=size.small, xloc=xloc.bar_time)
for i = 1 to levels
upper = decp + ab_gap * i
lower = decp - be_gap * i
ul1 = decp + uma
ul2 = decp + umb
ll1 = decp - lma
ll2 = decp - lmb
line.new(prev_time, upper, tim, upper, xloc.bar_time, color=#cf7d0a,
width=wi, style=line.style_solid)
line.new(prev_time, lower, tim, lower, xloc.bar_time, color=#cf7d0a,
width=wi, style=line.style_solid)
if pslab
label.new(prev_time, upper, text="R" + str.tostring(i) + ":" +
str.tostring(upper, "#.####") + " " + tfLabel, style=label.style_label_right,color
=color.white, textcolor=#02091c, size=size.small, xloc=xloc.bar_time)
label.new(prev_time, lower, text="S" + str.tostring(i) + ":" +
str.tostring(lower, "#.####") + " " + tfLabel, style=label.style_label_right,color
=color.white, textcolor=#02091c, size=size.small, xloc=xloc.bar_time)
if i == 1
up1 = decp + ab_gap / 2
dw1 = decp - be_gap / 2
line.new(prev_time, up1 , tim, up1, xloc.bar_time, color=#10b36f,
width=wi)
line.new(prev_time, dw1 , tim, dw1, xloc.bar_time, color=#10b36f,
width=wi)
if smid
line.new(prev_time, ul1 , tim, ul1, xloc.bar_time,
color=#2114d7, width=wi, style = line.style_dotted)
line.new(prev_time, ul2 , tim, ul2, xloc.bar_time,
color=#2114d7, width=wi, style = line.style_dotted)
line.new(prev_time, ll1 , tim, ll1, xloc.bar_time,
color=#2114d7, width=wi, style = line.style_dotted)
line.new(prev_time, ll2 , tim, ll2, xloc.bar_time,
color=#2114d7, width=wi, style = line.style_dotted)
if pslab
label.new(prev_time, up1, text=str.tostring(up1, "#.####"),
style=label.style_label_right, color =color.white, textcolor=#02091c,
size=size.small, xloc=xloc.bar_time)
label.new(prev_time, dw1, text=str.tostring(dw1, "#.####"),
style=label.style_label_right, color =color.white, textcolor=#02091c,
size=size.small, xloc=xloc.bar_time)
else
mid_upper = decp + ab_gap * (i - 0.5)
mid_lower = decp - be_gap * (i - 0.5)
ul12 = decp + ab_gap * (i - 0.75)
ul22 = decp + ab_gap * (i - 0.25)
ll12 = decp - be_gap * (i - 0.75)
ll22 = decp - be_gap * (i - 0.25)
line.new(prev_time, mid_upper, tim, mid_upper, xloc.bar_time,
color=#10b36f, width=wi)
line.new(prev_time, mid_lower, tim, mid_lower, xloc.bar_time,
color=#10b36f, width=wi)
if smid
line.new(prev_time, ul12 , tim, ul12, xloc.bar_time,
color=#2114d7, width=wi, style = line.style_dotted)
line.new(prev_time, ul22 , tim, ul22, xloc.bar_time,
color=#2114d7, width=wi, style = line.style_dotted)
line.new(prev_time, ll12 , tim, ll12, xloc.bar_time,
color=#2114d7, width=wi, style = line.style_dotted)
line.new(prev_time, ll22 , tim, ll22, xloc.bar_time,
color=#2114d7, width=wi, style = line.style_dotted)
if pslab
label.new(prev_time, mid_upper, text=str.tostring(mid_upper,
"#.####"), style=label.style_label_right, color =color.white, textcolor=#02091c,
size=size.small, xloc=xloc.bar_time)
label.new(prev_time, mid_lower, text=str.tostring(mid_lower,
"#.####"), style=label.style_label_right, color =color.white, textcolor=#02091c,
size=size.small, xloc=xloc.bar_time)
decp := dec
prev_time := tim
if slab
new_ab_label = label.new(x=bar_index + 10, y=ab_y, text="R" +
str.tostring(i) + "(" + gftf + "): " + str.tostring(ab_y, ' : 0.00'),
xloc=xloc.bar_index, yloc=yloc.price, color=color.white,
style=label.style_text_outline, textcolor=#04011a, size=size.normal,
textalign=text.align_right)
new_be_label = label.new(x=bar_index + 10, y=be_y, text="S" +
str.tostring(i) + "(" + gftf + "): " + str.tostring(be_y, ' : 0.00'),
xloc=xloc.bar_index, yloc=yloc.price, color=color.white,
style=label.style_text_outline, textcolor=#04011a, size=size.normal,
textalign=text.align_right)
array.set(abLabels, i - 1, new_ab_label)
array.set(beLabels, i - 1, new_be_label)
// Mid levels
mid_ab_y = dec + ab_gap * (i - 0.5)
qur1 = dec + ab_gap * (i - 0.25)
qur2 = dec + ab_gap * (i - 0.75)
mid_be_y = dec - be_gap * (i - 0.5)
qur3 = dec - be_gap * (i - 0.25)
qur4 = dec - be_gap * (i - 0.75)
if smid
q1_line = updateLine(array.get(q1abLines, i - 1), qur1, #2114d7,
line.style_dotted)
array.set(q1abLines, i - 1, q1_line)
q2_line = updateLine(array.get(q2abLines, i - 1), qur2, #2114d7,
line.style_dotted)
array.set(q2abLines, i - 1, q2_line)
q3_line = updateLine(array.get(q3beLines, i - 1), qur3, #2114d7,
line.style_dotted)
array.set(q3beLines, i - 1, q3_line)
q4_line = updateLine(array.get(q4beLines, i - 1), qur4, #2114d7,
line.style_dotted)
array.set(q4beLines, i - 1, q4_line)
// Delete old mid-level labels
old_abm_label = array.get(abMidLabels, i - 1)
old_bem_label = array.get(beMidLabels, i - 1)
old_qu1_label = array.get(qu1Labels, i - 1)
old_qu2_label = array.get(qu2Labels, i - 1)
old_qu3_label = array.get(qu3Labels, i - 1)
old_qu4_label = array.get(qu4Labels, i - 1)
if not na(old_abm_label)
label.delete(old_abm_label)
if not na(old_bem_label)
label.delete(old_bem_label)
if not na(old_qu1_label)
label.delete(old_qu1_label)
if not na(old_qu2_label)
label.delete(old_qu2_label)
if not na(old_qu3_label)
label.delete(old_qu3_label)
if not na(old_qu4_label)
label.delete(old_qu4_label)
array.set(qu1Labels, i - 1, new_qu1_label)
array.set(qu2Labels, i - 1, new_qu2_label)
array.set(qu3Labels, i - 1, new_qu3_label)
array.set(qu4Labels, i - 1, new_qu4_label)