text 1
text 1
// ZigZag Settings
Depth = input.int(12, 'Depth', minval=1, step=1, group="ZigZag Config")
Deviation = input.int(5, 'Deviation', minval=1, step=1, group="ZigZag Config")
Backstep = input.int(2, 'Backstep', minval=2, step=1, group="ZigZag Config")
// Display Settings
show_HH = input(true, "Show Higher High (HH)", group="Label Display")
show_LL = input(true, "Show Lower Low (LL)", group="Label Display")
show_HL = input(true, "Show Higher Low (HL)", group="Label Display")
show_LH = input(true, "Show Lower High (LH)", group="Label Display")
if bool(ta.change(direction))
lastPoint := z1.price[1]
line zz = na
label point = na
if repaint
zz := line.new(z1, z2, xloc.bar_time, extend? extend.right: extend.none,
color.new(direction>0? upcolor: dncolor, lines), width=line_thick)
if showLabel
point := label.new(z2, nowPoint, xloc.bar_time, yloc.price,
color.new(direction<0? upcolor: dncolor, labels), direction>0?
label.style_label_down: label.style_label_up, color.new(direction>0? upcolor:
dncolor, labels), label_size)
if direction == direction[1]
line.delete(zz[1])
label.delete(point[1])
else
line.set_extend(zz[1], extend.none)
else
if direction != direction[1]
zz := line.new(z1[1], z2[1], xloc.bar_time, extend.none,
color.new(direction>0? upcolor: dncolor, lines), width=line_thick)
if showLabel
point := label.new(z2[1], nowPoint, xloc.bar_time, yloc.price,
color.new(direction[1]<0? upcolor: dncolor, labels), direction[1]>0?
label.style_label_down: label.style_label_up, color.new(direction[1]>0? upcolor:
dncolor, labels), label_size)
// Alerts
alertcondition(nowPoint == "HH" and z2.price != z2.price[1] and show_HH, "New
Higher High", 'Zigzag on {{ticker}} higher high detected at {{time}}')
alertcondition(nowPoint == "LH" and z2.price != z2.price[1] and show_LH, "New Lower
High", 'Zigzag on {{ticker}} lower high detected at {{time}}')
alertcondition(nowPoint == "HL" and z2.price != z2.price[1] and show_HL, "New
Higher Low", 'Zigzag on {{ticker}} higher low detected at {{time}}')
alertcondition(nowPoint == "LL" and z2.price != z2.price[1] and show_LL, "New Lower
Low", 'Zigzag on {{ticker}} lower low detected at {{time}}')
if direction != direction[1]
alert((direction<0? "Bearish": "Bullish") + " Direction Final ",
alert.freq_once_per_bar_close)