0% found this document useful (0 votes)
17 views

text 1

The document is a Pine Script code for a custom technical indicator called 'ZigZag++', which is used for identifying price trends in financial markets. It allows users to configure various settings such as depth, deviation, and display options for higher highs, lower lows, and line styles. Additionally, the script includes alert conditions for significant price movements and direction changes.

Uploaded by

ha7690937
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)
17 views

text 1

The document is a Pine Script code for a custom technical indicator called 'ZigZag++', which is used for identifying price trends in financial markets. It allows users to configure various settings such as depth, deviation, and display options for higher highs, lower lows, and line styles. Additionally, the script includes alert conditions for significant price movements and direction changes.

Uploaded by

ha7690937
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
You are on page 1/ 2

//@version=5

indicator('ZigZag++', 'ZigZag++ [LD]', true, format.price, max_labels_count=200,


max_lines_count=50)

import DevLucem/ZigLib/1 as ZigZag

// 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")

line_thick = input.int(2, 'Line Thickness', minval=1, maxval=4, group="Lines")


labels = input(0, "Labels Transparency", group="Labels")
upcolor = input(color.lime, 'Bull Color', group="Colors")
dncolor = input(color.red, 'Bear Color', group="Colors")
lines = input(0, "Lines Transparency", group="Lines")
background = input(80, "Background Transparency", group="Colors")

label_size = switch input.int(3, "Label Size", minval=1, maxval=5, group="Labels")


1 => size.tiny
2 => size.small
3 => size.normal
4 => size.large
5 => size.huge

repaint = input(true, 'Repaint Levels')


extend = input(false, "Extend ZigZag", group="Lines")

[direction, z1, z2] = ZigZag.zigzag(low, high, Depth, Deviation, Backstep)


string nowPoint = ""
var float lastPoint = z1.price[1]

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)

nowPoint := direction<0? (z2.price<lastPoint? "LL": "HL"): (z2.price>lastPoint?


"HH": "LH")

// Check if label should be displayed


bool showLabel = (nowPoint == "HH" and show_HH) or (nowPoint == "LL" and
show_LL) or
(nowPoint == "HL" and show_HL) or (nowPoint == "LH" and
show_LH)

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)

nowPoint := direction[1]<0? (z2.price[1]<lastPoint[1]? "LL": "HL"):


(z2.price[1]>lastPoint[1]? "HH": "LH")

bool showLabel = (nowPoint == "HH" and show_HH) or (nowPoint == "LL" and


show_LL) or
(nowPoint == "HL" and show_HL) or (nowPoint == "LH" and
show_LH)

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)

bgcolor(direction<0? color.new(dncolor, background): color.new(upcolor,


background), title='Direction Background')

plotarrow(direction, "direction", display=display.status_line)

// 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}}')

alertcondition(direction != direction[1], 'Direction Changed', 'Zigzag on


{{ticker}} direction changed at {{time}}')
alertcondition(direction != direction[1] and direction>0, 'Bullish Direction',
'Zigzag on {{ticker}} bullish direction at {{time}}')
alertcondition(direction != direction[1] and direction<0, 'Bearish Direction',
'Zigzag on {{ticker}} bearish direction at {{time}}')

if direction != direction[1]
alert((direction<0? "Bearish": "Bullish") + " Direction Final ",
alert.freq_once_per_bar_close)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy