PINE LIBRARY

ZigZag Library [TradingFinder]

🔵Introduction

The "Zig Zag" indicator is an analytical tool that emerges from pricing changes. Essentially, it connects consecutive high and low points in an oscillatory manner. This method helps decipher price changes and can also be useful in identifying traditional patterns.

By sifting through partial price changes, "Zig Zag" can effectively pinpoint price fluctuations within defined time intervals.

🔵Key Features

1.Drawing the Zig Zag based on Pivot points:

The algorithm is based on pivots that operate consecutively and alternately (switch between high and low swing). In this way, zigzag lines are connected from a swing high to a swing low and from a swing low to a swing high.

Also, with a very low probability, it is possible to have both low pivots and high pivots in one candle. In these cases, the algorithm tries to make the best decision to make the most suitable choice.

You can control what period these decisions are based on through the "PiPe" parameter.

snapshot

2.Naming and labeling each pivot based on its position as "Higher High" (HH), "Lower Low" (LL), "Higher Low" (HL), and "Lower High" (LH).

Additionally, classic patterns such as HH, LH, LL, and HL can be recognized. All traders analyzing financial markets using classic patterns and Elliot Waves can benefit from the "zigzag" indicator to facilitate their analysis.

"HH": When the price is higher than the previous peak (Higher High).
"HL": When the price is higher than the previous low (Higher Low).
"LH": When the price is lower than the previous peak (Lower High).
"LL": When the price is lower than the previous low (Lower Low).

snapshot

🔵How to Use

First, you can add the library to your code as shown in the example below.


Function "ZigZag" Parameters:

🟣Logical Parameters

1.HIGH: You should place the "high" value here. High is a float variable.

2.LOW: You should place the "low" value here. Low is a float variable.

3.BAR_INDEX: You should place the "bar_index" value here. Bar_index is an integer variable.

4.PiPe: The desired pivot period for plotting Zig Zag is placed in this parameter. For example, if you intend to draw a Zig Zag with a Swing Period of 5, you should input 5.
PiPe is an integer variable.

Important:

Apart from the "PiPe" indicator, which is part of the customization capabilities of this indicator, you can create a multi-time frame mode for the indicator using 3 parameters "High", "Low" and "BAR_INDEX". In this way, instead of the data of the current time frame, use the data of other time frames.

Note that it is better to use the current time frame data, because using the multi-time frame mode is associated with challenges that may cause bugs in your code.

snapshot

🟣Setting Parameters

5.SHOW_LINE: It's a boolean variable. When true, the Zig Zag line is displayed, and when false, the Zig Zag line display is disabled.

6.STYLE_LINE: In this variable, you can determine the style of the Zig Zag line. You can input one of the 3 options: line.style_solid, line.style_dotted, line.style_dashed. STYLE_LINE is a constant string variable.

7.COLOR_LINE: This variable takes the input of the line color.


8.WIDTH_LINE: The input for this variable is a number from 1 to 3, which is used to adjust the thickness of the line that draws the Zig Zag. WIDTH_LINE is an integer variable.

9.SHOW_LABEL: It's a boolean variable. When true, labels are displayed, and when false, label display is disabled.

10.COLOR_LABEL: The color of the labels is set in this variable.


11.SIZE_LABEL: The size of the labels is set in this variable. You should input one of the following options: size.auto, size.tiny, size.small, size.normal, size.large, size.huge.

12.Show_Support: It's a boolean variable that, when true, plots the last support line, and when false, disables its plotting.

13.Show_Resistance: It's a boolean variable that, when true, plots the last resistance line, and when false, disables its plotting.


Suggestion:
You can use the following code snippet to import Zig Zag into your code for time efficiency.


arraysdisplaylibrarysupply_and_demandsupportandresitancetechindicatortrendlineanalysistrendpatterntrendtradingZigzagzigzagcorrrectionzigzagpattern

Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.


Get Access to TradingFinder indicators and Education for FREE: tradingFinder.com/

Forex, Crypto, Stocks, Futures & Index informational materials and Trading Tools in Turkish language: tradingFinder.com/tr/
Also on:

Disclaimer