Market Structure Report Library [TradingFinder]🔵 Introduction 
Market Structure is one of the most fundamental concepts in Price Action and Smart Money theory. In simple terms, it represents how price moves between highs and lows and reveals which phase of the market cycle we are currently in uptrend, downtrend, or transition.
 Each structure in the market is formed by a combination of Breaks of Structure (BoS) and Changes of Character (CHoCH) :
 
 BoS occurs when the market breaks a previous high or low, confirming the continuation of the current trend.
 CHoCH occurs when price breaks in the opposite direction for the first time, signaling a potential trend reversal.
 
  
 Since price movement is inherently fractal, market structure can be analyzed on two distinct levels :
 
 Major / External Structure: represents the dominant macro trend.
 Minor / Internal Structure: represents corrective or smaller-scale movements within the larger trend.
 
🔵 Library Purpose 
The “Market Structure Report Library” is designed to automatically detect the current market structure type in real time.
Without drawing or displaying any visuals, it analyzes raw price data and returns a series of logical and textual outputs (Return Values) that describe the current structural state of the market.
 It provides the following information :
 Trend Type :
 
 External Trend (Major): Up Trend, Down Trend, No Trend
 Internal Trend (Minor): Up Trend, Down Trend, No Trend
 
 Structure Type :
 
 BoS : Confirms trend continuation
 CHoCH : Indicates a potential trend reversal
 
 Consecutive BoS Counter : Measures trend strength on both Major and Minor levels.
 Candle Type : Returns the current candle’s condition(Bullish, Bearish, Doji)
This library is specifically designed for use in Smart Money–based screeners, indicators, and algorithmic strategies.
It can analyze multiple symbols and timeframes simultaneously and return the exact structure type (BoS or CHoCH) and trend direction for each.
🔵 Function Outputs 
The function MS() processes the price data and returns seven key outputs,
each representing a distinct structural state of the market. These values can be used in indicators, strategies, or multi-symbol screeners.
🟣 ExternalTrend 
 Type : string
 Description : Represents the direction of the Major (External) market structure.
 Possible values :
 
 Up Trend
 Down Trend
 No Trend
 
This is determined based on the behavior of Major Pivots (swing highs/lows).
🟣 InternalTrend 
 Type : string
 Description : Represents the direction of the Minor (Internal) market structure.
 Possible values :
 
 Up Trend
 Down Trend
 No Trend
 
🟣 M_State 
 Type : string
 Description : Specifies the type of the latest Major Structure event.
 Possible values :
 
 BoS
 CHoCH
 
🟣 m_State 
 Type : string
 Description : Specifies the type of the latest Minor Structure event.
 Possible values :
 
 BoS
 CHoCH
 
🟣 MBoS_Counter 
 Type : integer
 Description : Counts the number of consecutive structural breaks (BoS) in the Major structure.
 Useful for evaluating trend strength :
 
 Increasing count: indicates trend continuation.
 Reset to zero: typically occurs after a CHoCH.
 
🟣 mBoS_Counter 
 Type : integer
 Description : Counts the number of consecutive structural breaks in the Minor structure.
Helps analyze the micro structure of the market on lower timeframes.
 Higher value : strong internal trend.
 Reset : indicates a minor pullback or reversal.
🟣 Candle_Type 
 Type : string
 Description : Represents the type of the current candle.
 Possible values :
 
 Bullish
 Bearish
 Doji
 
 import TFlab/Market_Structure_Report_Library_TradingFinder/1 as MSS
PP = input.int      (5       , 'Market Structure Pivot Period'                     , group = 'Symbol 1' )
        = MSS.MS(PP)
波浪分析
SITFX_FuturesSpec_v17SITFX_FuturesSpec_v17 – Universal Futures Contract Library
Full-scale futures contract specification library for Pine Script v6. Covers CME, CBOT, NYMEX, COMEX, CFE, Eurex, ICE, and more – including minis, micros, metals, energies, FX, and bonds.
Key Features:
✅ Instrument‑agnostic: ES/MES, NQ/MNQ, YM/MYM, RTY/M2K, metals, energies, FX, bonds
✅ Full contract data: Tick size, tick value, point value, margins
✅ Continuation‑safe: Single‑line logic, no arrays or continuation errors
✅ Foundation for SITFX tools: Gann, Fibs, structure, and risk modules
Usage example:
import SITFX_FuturesSpec_v17/1 as fs
spec = fs.get(syminfo.root)
label.new(bar_index, high, str.format("{0}: Tick={1}, Value=${2}", spec.name, spec.tickSize, spec.tickValue))
DrawZigZag🟩  OVERVIEW 
This library draws zigzag lines for existing pivots. It is designed to be simple to use. If your script creates pivots and you want to join them up while handling edge cases, this library does that quickly and efficiently. If you want your pivots created for you, choose one of the many other zigzag libraries that do that.
🟩  HOW TO USE 
Pine Script libraries contain reusable code for importing into indicators. You do not need to copy any code out of here. Just import the library and call the function you want.
For example, for version 1 of this library, import it like this:
 
import SimpleCryptoLife/DrawZigZag/1
 
See the EXAMPLE USAGE sections within the library for examples of calling the functions.
For more information on libraries and incorporating them into your scripts, see the  Libraries  section of the Pine Script User Manual. 
🟩  WHAT IT DOES 
I looked at every zigzag library on TradingView, after finishing this one. They all seemed to fall into two groups in terms of functionality:
 • Create the pivots themselves, using a combination of Williams-style pivots and sometimes price distance.
 • Require an array of pivot information, often in a format that uses user-defined types.
My library takes a completely different approach. 
Firstly, it only does the drawing. It doesn't calculate the pivots for you. This isn't laziness. There are so many ways to define pivots and that should be up to you. If you've followed my work on market structure you know what I think of Williams pivots.
Secondly, when you pass information about your pivots to the library function, you only need the minimum of pivot information -- whether it's a High or Low pivot, the price, and the bar index. Pass these as normal variables -- bools, ints, and floats -- on the fly as your pivots confirm. It is completely agnostic as to how you derive your pivots. If they are confirmed an arbitrary number of bars after they happen, that's fine.
So why even bother using it if all it does it draw some lines?
Turns out there is quite some logic needed in order to connect highs and lows in the right way, and to handle edge cases. This is the kind of thing one can happily outsource.
🟩  THE RULES 
 • Zigs and zags must alternate between Highs and Lows. We never connect a High to a High or a Low to a Low.
 • If a candle has both a High and Low pivot confirmed on it, the first line is drawn to the end of the candle that is the opposite to the previous pivot. Then the next line goes vertically through the candle to the other end, and then after that continues normally.
 • If we draw a line up from a Low to a High pivot, and another High pivot comes in higher, we *extend* the line up, and the same for lines down. Yes this is a form of repainting. It is in my opinion the only way to end up with a correct structure.
 • We ignore lower highs on the way up and higher lows on the way down.
🟩  WHAT'S COOL ABOUT THIS LIBRARY 
 • It's simple and lightweight: no exported user-defined types, no helper methods, no matrices.
 • It's really fast. In my profiling it runs at about ~50ms, and changing the options (e.g., trimming the array) doesn't make very much difference.
 • You only need to call one function, which does all the calculations and draws all lines.
 • There are two variations of this function though -- one simple function that just draws lines, and one slightly more advanced method that modifies an array containing the lines. If you don't know which one you want, use the simpler one.
🟩  GEEK STUFF 
 • There are no dependencies on other libraries.
 • I tried to make the logic as clear as I could and comment it appropriately.
 • In the `f_drawZigZags` function, the line variable is declared using the `var` keyword *inside* the function, for simplicity. For this reason, it persists between function calls *only* if the function is called from the global scope or a local if block. In general, if a function is called  from inside a loop , or multiple times from different contexts, persistent variables inside that function are  re-initialised  on each call. In this case, this re-initialisation would mean that the function loses track of the previous line, resulting in incorrect drawings. This is why you cannot call the `f_drawZigZags` function from a loop (not that there's any reason to). The `m_drawZigZagsArray` does not use any internal `var` variables.
 • The function itself takes a Boolean parameter `_showZigZag`, which turns the drawings on and off, so there is no need to call the function conditionally. In the examples, we do call the functions from an if block, purely as an illustration of how to increase performance by restricting the amount of code that needs to be run.
🟩  BRING ON THE FUNCTIONS 
 f_drawZigZags(_showZigZag, _isHighPivot, _isLowPivot, _highPivotPrice, _lowPivotPrice, _pivotIndex, _zigzagWidth, _lineStyle, _upZigColour, _downZagColour) 
  This function creates or extends the latest zigzag line. Takes real-time information about pivots and draws lines. It does not calculate the pivots. It must be called once per script and cannot be called from a loop.
  Parameters:
     _showZigZag (bool) : Whether to show the zigzag lines.
     _isHighPivot (bool) : Whether the current bar confirms a high pivot. Note that pivots are confirmed after the bar in which they occur.
     _isLowPivot (bool) : Whether the current bar confirms a low pivot.
     _highPivotPrice (float) : The price of the high pivot that was confirmed this bar. It is NOT the high price of the current bar.
     _lowPivotPrice (float) : The price of the low pivot that was confirmed this bar. It is NOT the low price of the current bar.
     _pivotIndex (int) : The bar index of the pivot that was confirmed this bar. This is not an offset. It's the `bar_index` value of the pivot.
     _zigzagWidth (int) : The width of the zigzag lines.
     _lineStyle (string) : The style of the zigzag lines.
     _upZigColour (color) : The colour of the up zigzag lines.
     _downZagColour (color) : The colour of the down zigzag lines.
  Returns: The function has no explicit returns. As a side effect, it draws or updates zigzag lines.
 method m_drawZigZagsArray(_a_zigZagLines, _showZigZag, _isHighPivot, _isLowPivot, _highPivotPrice, _lowPivotPrice, _pivotIndex, _zigzagWidth, _lineStyle, _upZigColour, _downZagColour, _trimArray) 
  Namespace types: array
  Parameters:
     _a_zigZagLines (array) 
     _showZigZag (bool) : Whether to show the zigzag lines.
     _isHighPivot (bool) : Whether the current bar confirms a high pivot. Note that pivots are usually confirmed after the bar in which they occur.
     _isLowPivot (bool) : Whether the current bar confirms a low pivot.
     _highPivotPrice (float) : The price of the high pivot that was confirmed this bar. It is NOT the high price of the current bar.
     _lowPivotPrice (float) : The price of the low pivot that was confirmed this bar. It is NOT the low price of the current bar.
     _pivotIndex (int) : The bar index of the pivot that was confirmed this bar. This is not an offset. It's the `bar_index` value of the pivot.
     _zigzagWidth (int) : The width of the zigzag lines.
     _lineStyle (string) : The style of the zigzag lines.
     _upZigColour (color) : The colour of the up zigzag lines.
     _downZagColour (color) : The colour of the down zigzag lines.
     _trimArray (bool) : If true, the array of lines is kept to a maximum size of two lines (the line elements are not deleted). If false (the default), the array is kept to a maximum of 500 lines (the maximum number of line objects a single Pine script can display).
  Returns: This function has no explicit returns but it modifies a global array of zigzag lines.
ZigZag█ Overview 
This Pine Script™ library provides a comprehensive implementation of the ZigZag indicator using advanced object-oriented programming techniques. It serves as a developer resource rather than a standalone indicator, enabling Pine Script™ programmers to incorporate sophisticated ZigZag calculations into their own scripts.
Pine Script™ libraries contain reusable code that can be imported into indicators, strategies, and other libraries. For more information, consult the Libraries section of the Pine Script™ User Manual.
 █ About the Original 
This library is based on  TradingView's official ZigZag implementation .
The original code provides a solid foundation with user-defined types and methods for calculating ZigZag pivot points.
 █ What is ZigZag? 
The ZigZag indicator filters out minor price movements to highlight significant market trends.
It works by:
1. Identifying significant pivot points (local highs and lows)
2. Connecting these points with straight lines
3. Ignoring smaller price movements that fall below a specified threshold
Traders typically use ZigZag for:
- Trend confirmation
- Identifying support and resistance levels
- Pattern recognition (such as Elliott Waves)
- Filtering out market noise
The algorithm identifies pivot points by analyzing price action over a specified number of bars, then only changes direction when price movement exceeds a user-defined percentage threshold.
 █ My Enhancements 
This modified version extends the original library with several key improvements:
1. Support and Resistance Visualization
   - Adds horizontal lines at pivot points
   - Customizable line length (offset from pivot)
   - Adjustable line width and color
   - Option to extend lines to the right edge of the chart
2. Support and Resistance Zones
   - Creates semi-transparent zone areas around pivot points
   - Customizable width for better visibility of important price levels
   - Separate colors for support (lows) and resistance (highs)
   - Visual representation of price areas rather than just single lines
3. Zig Zag Lines
   - Separate colors for upward and downward ZigZag movements
   - Visually distinguishes between bullish and bearish price swings
   - Customizable colors for text
   - Width customization
4. Enhanced Settings Structure
   - Added new fields to the Settings type to support the additional features
   - Extended Pivot type with supportResistance and supportResistanceZone fields
   - Comprehensive configuration options for visual elements
These enhancements make the ZigZag more useful for technical analysis by clearly highlighting support/resistance levels and zones, and providing clearer visual cues about market direction.
█ Technical Implementation
This library leverages Pine Script™'s user-defined types (UDTs) to create a robust object-oriented architecture:
-  Settings : Stores configuration parameters for calculation and display
-  Pivot : Represents pivot points with their visual elements and properties
-  ZigZag : Manages the overall state and behavior of the indicator
The implementation follows best practices from the Pine Script™ User Manual's Style Guide and uses advanced language features like methods and object references. These UDTs represent Pine Script™'s most advanced feature set, enabling sophisticated data structures and improved code organization.
For newcomers to Pine Script™, it's recommended to understand the language fundamentals before working with the UDT implementation in this library.
 █ Usage Example 
 
//@version=6
indicator("ZigZag Example", overlay = true, shorttitle = 'ZZA', max_bars_back = 5000, max_lines_count = 500, max_labels_count = 500, max_boxes_count = 500)
import andre_007/ZigZag/1 as ZIG
var group_1 = "ZigZag Settings"
//@variable Draw Zig Zag on the chart.
bool showZigZag = input.bool(true, "Show Zig-Zag Lines", group = group_1, tooltip = "If checked, the Zig Zag will be drawn on the chart.", inline = "1")
// @variable The deviation percentage from the last local high or low required to form a new Zig Zag point.
float deviationInput = input.float(5.0, "Deviation (%)", minval = 0.00001, maxval = 100.0,
  tooltip = "The minimum percentage deviation from a previous pivot point required to change the Zig Zag's direction.", group = group_1, inline = "2")
// @variable The number of bars required for pivot detection.
int depthInput = input.int(10, "Depth", minval = 1, tooltip = "The number of bars required for pivot point detection.", group = group_1, inline = "3")
// @variable registerPivot (series bool) Optional. If `true`, the function compares a detected pivot 
// point's coordinates to the latest `Pivot` object's `end` chart point, then 
// updates the latest `Pivot` instance or adds a new instance to the `ZigZag` 
// object's `pivots` array. If `false`, it does not modify the `ZigZag` object's 
// data. The default is `true`. 
bool allowZigZagOnOneBarInput = input.bool(true, "Allow Zig Zag on One Bar", tooltip = "If checked, the Zig Zag calculation can register a pivot high and pivot low on the same bar.",
  group = group_1, inline = "allowZigZagOnOneBar")
var group_2 = "Display Settings"
// @variable The color of the Zig Zag's lines (up).
color lineColorUpInput = input.color(color.green, "Line Colors for Up/Down", group = group_2, inline = "4")
// @variable The color of the Zig Zag's lines (down).
color lineColorDownInput = input.color(color.red, "", group = group_2, inline = "4",
  tooltip = "The color of the Zig Zag's lines")
// @variable The width of the Zig Zag's lines.
int lineWidthInput = input.int(1, "Line Width", minval = 1, tooltip = "The width of the Zig Zag's lines.", group = group_2, inline = "w")
// @variable If `true`, the Zig Zag will also display a line connecting the last known pivot to the current `close`.
bool extendInput = input.bool(true, "Extend to Last Bar", tooltip = "If checked, the last pivot will be connected to the current close.",
  group = group_1, inline = "5")
// @variable If `true`, the pivot labels will display their price values.
bool showPriceInput = input.bool(true, "Display Reversal Price", 
  tooltip = "If checked, the pivot labels will display their price values.", group = group_2, inline = "6")
// @variable If `true`, each pivot label will display the volume accumulated since the previous pivot.
bool showVolInput = input.bool(true, "Display Cumulative Volume",
  tooltip = "If checked, the pivot labels will display the volume accumulated since the previous pivot.", group = group_2, inline = "7")
// @variable If `true`, each pivot label will display the change in price from the previous pivot.
bool showChgInput = input.bool(true, "Display Reversal Price Change", 
  tooltip = "If checked, the pivot labels will display the change in price from the previous pivot.", group = group_2, inline = "8")
// @variable Controls whether the labels show price changes as raw values or percentages when `showChgInput` is `true`.
string priceDiffInput = input.string("Absolute", "", options =  ,  
  tooltip = "Controls whether the labels show price changes as raw values or percentages when 'Display Reversal Price Change' is checked.",
  group = group_2, inline = "8")
// @variable If `true`, the Zig Zag will display support and resistance lines.
bool showSupportResistanceInput = input.bool(true, "Show Support/Resistance Lines",
  tooltip = "If checked, the Zig Zag will display support and resistance lines.", group = group_2, inline = "9")
// @variable The number of bars to extend the support and resistance lines from the last pivot point.
int supportResistanceOffsetInput = input.int(50, "Support/Resistance Offset", minval = 0, 
  tooltip = "The number of bars to extend the support and resistance lines from the last pivot point.", group = group_2, inline = "10")
// @variable The width of the support and resistance lines.
int supportResistanceWidthInput = input.int(1, "Support/Resistance Width", minval = 1, 
  tooltip = "The width of the support and resistance lines.", group = group_2, inline = "11")
// @variable The color of the support lines.
color supportColorInput = input.color(color.red, "Support/Resistance Color", group = group_2, inline = "12")
// @variable The color of the resistance lines.
color resistanceColorInput = input.color(color.green, "", group = group_2, inline = "12",
  tooltip = "The color of the support/resistance lines.")
// @variable If `true`, the support and resistance lines will be drawn as zones.
bool showSupportResistanceZoneInput = input.bool(true, "Show Support/Resistance Zones",
  tooltip = "If checked, the support and resistance lines will be drawn as zones.", group = group_2, inline = "12-1")
// @variable The color of the support zones.
color supportZoneColorInput = input.color(color.new(color.red, 70), "Support Zone Color", group = group_2, inline = "12-2")
// @variable The color of the resistance zones.
color resistanceZoneColorInput = input.color(color.new(color.green, 70), "", group = group_2, inline = "12-2",
  tooltip = "The color of the support/resistance zones.")
// @variable The width of the support and resistance zones.
int supportResistanceZoneWidthInput = input.int(10, "Support/Resistance Zone Width", minval = 1, 
  tooltip = "The width of the support and resistance zones.", group = group_2, inline = "12-3")
// @variable If `true`, the support and resistance lines will extend to the right of the chart.
bool supportResistanceExtendInput = input.bool(false, "Extend to Right",
  tooltip = "If checked, the lines will extend to the right of the chart.", group = group_2, inline = "13")
// @variable References a `Settings` instance that defines the `ZigZag` object's calculation and display properties.
var ZIG.Settings settings = 
 ZIG.Settings.new(
     devThreshold               = deviationInput,
     depth                      = depthInput,
     lineColorUp                = lineColorUpInput,
     lineColorDown              = lineColorDownInput,
     textUpColor                = lineColorUpInput,
     textDownColor              = lineColorDownInput,
     lineWidth                  = lineWidthInput,
     extendLast                 = extendInput,
     displayReversalPrice       = showPriceInput,
     displayCumulativeVolume    = showVolInput,
     displayReversalPriceChange = showChgInput,
     differencePriceMode        = priceDiffInput,
     draw                       = showZigZag,
     allowZigZagOnOneBar        = allowZigZagOnOneBarInput,
     drawSupportResistance      = showSupportResistanceInput,
     supportResistanceOffset    = supportResistanceOffsetInput,
     supportResistanceWidth     = supportResistanceWidthInput,
     supportColor               = supportColorInput,
     resistanceColor            = resistanceColorInput,
     supportResistanceExtend    = supportResistanceExtendInput,
     supportResistanceZoneWidth = supportResistanceZoneWidthInput,
     drawSupportResistanceZone  = showSupportResistanceZoneInput,
     supportZoneColor           = supportZoneColorInput,
     resistanceZoneColor        = resistanceZoneColorInput     
 )
// @variable References a `ZigZag` object created using the `settings`.
var ZIG.ZigZag zigZag = ZIG.newInstance(settings)
// Update the `zigZag` on every bar.
zigZag.update()
//#endregion
 
The example code demonstrates how to create a ZigZag indicator with customizable settings. It:
1. Creates a Settings object with user-defined parameters
2. Instantiates a ZigZag object using these settings
3. Updates the ZigZag on each bar to detect new pivot points
4. Automatically draws lines and labels when pivots are detected
This approach provides maximum flexibility while maintaining readability and ease of use.
Harmonic Patterns Library [TradingFinder]🔵 Introduction 
Harmonic patterns blend geometric shapes with Fibonacci numbers, making these numbers fundamental to understanding the patterns.
One person who has done a lot of research on harmonic patterns is Scott Carney.Scott Carney's research on harmonic patterns in technical analysis focuses on precise price structures based on Fibonacci ratios to identify market reversals. 
Key patterns include the Gartley, Bat, Butterfly, and Crab, each with specific alignment criteria. These patterns help traders anticipate potential market turning points and make informed trading decisions, enhancing the predictability of technical analysis.
🟣 Understanding 5-Point Harmonic Patterns 
In the current library version, you can easily draw and customize most XABCD patterns. These patterns often form M or W shapes, or a combination of both. By calculating the Fibonacci ratios between key points, you can estimate potential price movements. 
All five-point patterns share a similar structure, differing only in line lengths and Fibonacci ratios. Learning one pattern simplifies understanding others.
  
🟣 Exploring the Gartley Pattern 
The Gartley pattern appears in both bullish (M shape) and bearish (W shape) forms. In the bullish Gartley, point X is below point D, and point A surpasses point C. Point D marks the start of a strong upward trend, making it an optimal point to place a buy order. 
The bearish Gartley mirrors the bullish pattern with inverted Fibonacci ratios. In this scenario, point D indicates the start of a significant price drop. Traders can place sell orders at this point and buy at lower prices for profit in two-way markets.
🟣 Analyzing the Butterfly Pattern 
The Butterfly pattern also manifests in bullish (M shape) and bearish (W shape) forms. It resembles the Gartley pattern but with point D lower than point X in the bullish version. 
The Butterfly pattern involves deeper price corrections than the Gartley, leading to more significant price fluctuations. Point D in the bullish Butterfly indicates the beginning of a sharp price rise, making it an entry point for buy orders. 
The bearish Butterfly has inverted Fibonacci ratios, with point D marking the start of a sharp price decline, ideal for sell orders followed by buying at lower prices in two-way markets.
🟣 Insights into the Bat Pattern 
The Bat pattern, appearing in bullish (M shape) and bearish (W shape) forms, is one of the most precise harmonic patterns. It closely resembles the Butterfly and Gartley patterns, differing mainly in Fibonacci levels. 
The bearish Bat pattern shares the Fibonacci ratios with the bullish Bat, with an inverted structure. Point D in the bearish Bat marks the start of a significant price drop, suitable for sell orders followed by buying at lower prices for profit.
🟣 The Crab Pattern Explained 
The Crab pattern, found in both bullish (M shape) and bearish (W shape) forms, is highly favored by analysts. Discovered in 2000, the Crab pattern features a larger final wave correction compared to other harmonic patterns. 
The bearish Crab shares Fibonacci ratios with the bullish version but in an inverted form. Point D in the bearish Crab signifies the start of a sharp price decline, making it an ideal point for sell orders followed by buying at lower prices for profitable trades.
🟣 Understanding the Shark Pattern 
The Shark pattern appears in bullish (M shape) and bearish (W shape) forms. It differs from previous patterns as point C in the bullish Shark surpasses point A, with unique level measurements. 
The bearish Shark pattern mirrors the Fibonacci ratios of the bullish Shark but is inverted. Point D in the bearish Shark indicates the start of a sharp price drop, ideal for placing sell orders and buying at lower prices to capitalize on the pattern.
🟣 The Cypher Pattern Overview 
The Cypher pattern is another that appears in both bullish (M shape) and bearish (W shape) forms. It resembles the Shark pattern, with point C in the bullish Cypher extending beyond point A, and point D forming within the XA line. 
The bearish Cypher shares the Fibonacci ratios with the bullish Cypher but in an inverted structure. Point D in the bearish Cypher marks the start of a significant price drop, perfect for sell orders followed by buying at lower prices.
🟣 Introducing the Nen-Star Pattern 
The Nen-Star pattern appears in both bullish (M shape) and bearish (W shape) forms. In the bullish Nen-Star, point C extends beyond point A, and point D, the final point, forms outside the XA line, making CD the longest wave. 
The bearish Nen-Star has inverted Fibonacci ratios, with point D indicating the start of a significant price drop. Traders can place sell orders at point D and buy at lower prices to profit from this pattern in two-way markets.
The 5-point harmonic patterns, commonly referred to as XABCD patterns, are specific geometric price structures identified in financial markets. These patterns are used by traders to predict potential price movements based on historical price data and Fibonacci retracement levels. 
 Here are the main 5-point harmonic patterns :
 
 Gartley Pattern
 Anti-Gartley Pattern
 Bat Pattern
 Anti-Bat Pattern
 Alternate Bat Pattern
 Butterfly Pattern
 Anti-Butterfly Pattern
 Crab Pattern	
 Anti-Crab Pattern
 Deep Crab Pattern
 Shark Pattern
 Anti- Shark Pattern
 Anti Alternate Shark Pattern
 Cypher Pattern
 Anti-Cypher Pattern
 
 
🔵 How to Use 
To add "Order Block Refiner Library", you must first add the following code to your script.
 import TFlab/Harmonic_Chart_Pattern_Library_TradingFinder/1 as HP 
🟣 Parameters 
 XABCD(Name, Type, Show, Color, LineWidth, LabelSize, ShVF, FLPC, FLPCPeriod, Pivot, ABXAmin, ABXAmax, BCABmin, BCABmax, CDBCmin, CDBCmax, CDXAmin, CDXAmax) =>
Parameters: 
Name (string) 
Type (string) 
Show (bool) 
Color (color) 
LineWidth (int) 
LabelSize (string) 
ShVF (bool) 
FLPC (bool) 
FLPCPeriod (int) 
Pivot (int) 
ABXAmin (float) 
ABXAmax (float) 
BCABmin (float) 
BCABmax (float) 
CDBCmin (float) 
CDBCmax (float) 
CDXAmin (float) 
CDXAmax (float)
 
🟣 Genaral Parameters 
 Name : The name of the pattern.
 Type:  Enter "Bullish" to draw a Bullish pattern and "Bearish" to draw an Bearish pattern.
 Show : Enter "true" to display the template and "false" to not display the template.
 Color : Enter the desired color to draw the pattern in this parameter.
 LineWidth : You can enter the number 1 or numbers higher than one to adjust the thickness of the drawing lines. This number must be an integer and increases with increasing thickness.
 LabelSize : You can adjust the size of the labels by using the "size.auto", "size.tiny", "size.smal", "size.normal", "size.large" or "size.huge" entries.
🟣 Logical Parameters 
 ShVF : If this parameter is on "true" mode, only patterns will be displayed that they have exact format and no noise can be seen in them. If "false" is, the patterns displayed that maybe are noisy and do not exactly correspond to the original pattern.
  
 FLPC : if Turned on, you can see this ability of patterns when their last pivot is formed. If this feature is off, it will see the patterns as soon as they are formed. The advantage of this option being clear is less formation of fielded patterns, and it is accompanied by the lateest pattern seeing and a sharp reduction in reward to risk.
 FLPCPeriod : Using this parameter you can determine that the last pivot is based on Pivot period.
  
 Pivot : You need to determine the period of the zigzag indicator. This factor is the most important parameter in pattern recognition.
 ABXAmin : Minimum retracement of "AB" line compared to "XA" line.
 ABXAmax : Maximum retracement of "AB" line compared to "XA" line.
 BCABmin : Minimum retracement of "BC" line compared to "AB" line.
 BCABmax : Maximum retracement of "BC" line compared to "AB" line.
 CDBCmin : Minimum retracement of "CD" line compared to "BC" line.
 CDBCmax : Maximum retracement of "CD" line compared to "BC" line.
 CDXAmin : Minimum retracement of "CD" line compared to "XA" line.
 CDXAmax : Maximum retracement of "CD" line compared to "XA" line.
  
  
🟣 Function Outputs 
This library has two outputs. The first output is related to the alert of the formation of a new pattern. And the second output is related to the formation of the candlestick pattern and you can draw it using the "plotshape" tool.
 Candle Confirmation Logic :
  
 Example :
 import TFlab/Harmonic_Chart_Pattern_Library_TradingFinder/1 as HP
PP = input.int(3, 'ZigZag Pivot Period')
ShowBull = input.bool(true, 'Show Bullish Pattern')
ShowBear = input.bool(true, 'Show Bearish Pattern')
ColorBull = input.color(#0609bb, 'Color Bullish Pattern')
ColorBear = input.color(#0609bb, 'Color Bearish Pattern')
LineWidth = input.int(1 , 'Width Line')
LabelSize = input.string(size.small , 'Label size' , options =  )
ShVF = input.bool(false , 'Show Valid Format')
FLPC = input.bool(false , 'Show Formation Last Pivot Confirm')
FLPCPeriod =input.int(2, 'Period of Formation Last Pivot')
//Call function
  = HP.XABCD('Bullish Bat', 'Bullish', ShowBull, ColorBull , LineWidth, LabelSize ,ShVF,  FLPC, FLPCPeriod, PP, 0.382, 0.50, 0.382, 0.886, 1.618, 2.618, 0.85, 0.9)
  = HP.XABCD('Bearish Bat', 'Bearish', ShowBear, ColorBear , LineWidth, LabelSize ,ShVF,  FLPC, FLPCPeriod, PP, 0.382, 0.50, 0.382, 0.886, 1.618, 2.618, 0.85, 0.9)
//Alert
if BearAlert
    alert('Bearish Harmonic')
if BullAlert
    alert('Bulish Harmonic')
//CandleStick Confirm
plotshape(BearCandleConfirm, style = shape.arrowdown, color = color.red)
plotshape(BullCandleConfirm, style = shape.arrowup, color = color.green, location = location.belowbar )
 
Volatility_ZigZag_LibraryThis is a Pine Script library for the public indicator "Volatility ZigZag" by brettkind. For further description, please refer to the information available on the original indicator page.
Library   "Volatility_ZigZag_Library" 
 getValues_andStyling_VolatilityZigZag_byBrettkind(hl_src, SOURCE, length, min_dev_input, stdev_fctr, ZigZag, zz_color, zz_width, zz_devline, zz_points, zz_alert_sign, ZZ_Label, ZZ_Label_clr, rev_text, zz_bars_text, pcabs_text, avg_pcabs_text, pcrel_text, avg_pcrel_text, vol_text, avg_vol_text, input_currency) 
  Parameters:
     hl_src (bool) 
     SOURCE (float) 
     length (int) 
     min_dev_input (float) 
     stdev_fctr (float) 
     ZigZag (bool) 
     zz_color (color) 
     zz_width (int) 
     zz_devline (bool) 
     zz_points (bool) 
     zz_alert_sign (bool) 
     ZZ_Label (bool) 
     ZZ_Label_clr (color) 
     rev_text (bool) 
     zz_bars_text (bool) 
     pcabs_text (bool) 
     avg_pcabs_text (bool) 
     pcrel_text (bool) 
     avg_pcrel_text (bool) 
     vol_text (bool) 
     avg_vol_text (bool) 
     input_currency (string) 
 getStatisticTable_VolatilityZigZag_byBrettkind(x1, Y1_array, draw_tbl) 
  Parameters:
     x1 (int) 
     Y1_array (array) 
     draw_tbl (bool)
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.
  
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). 
  
🔵 How to Use  
First, you can add the library to your code as shown in the example below.
 import TFlab/ZigZagLibrary_TradingFinder/1 as ZZ 
 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.
  
🟣 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.
 //import Library
import TFlab/ZigZagLibrary_TradingFinder/1 as ZZ
// Input and Setting
// Zig Zag Line
ShZ = input.bool(true , 'Show Zig Zag Line', group = 'Zig Zag') //Show Zig Zag
PPZ = input.int(5 ,'Pivot Period Zig Zag Line' , group = 'Zig Zag') //Pivot Period Zig Zag
ZLS = input.string(line.style_dashed , 'Zig Zag Line Style' , options =  , group = 'Zig Zag' )
//Zig Zag Line Style
ZLC = input.color(color.rgb(0, 0, 0) , 'Zig Zag Line Color' , group = 'Zig Zag')  //Zig Zag Line Color
ZLW = input.int(1 , 'Zig Zag Line Width' , group = 'Zig Zag')//Zig Zag Line Width 
// Label
ShL = input.bool(true , 'Label', group = 'Label') //Show Label 
LC =  input.color(color.rgb(0, 0, 0) , 'Label Color' , group = 'Label')//Label Color
LS =  input.string(size.tiny , 'Label size' , options =  , group = 'Label' )//Label size
Show_Support= input.bool(false, 'Show Last Support',
 tooltip = 'Last Support' , group = 'Support and Resistance')
Show_Resistance = input.bool(false, 'Show Last Resistance',
 tooltip = 'Last Resistance' , group = 'Support and Resistance')
//Call Function
ZZ.ZigZag(high ,low ,bar_index ,PPZ , ShZ ,ZLS , ZLC, ZLW ,ShL , LC , LS , Show_Support , Show_Resistance ) 
ZigZag LibraryThis is yet another ZigZag library.
🔵 Key Features
1.  Lightning-Fast Performance : Optimized code ensures minimal lag and swift chart updates.
2.  Real-Time Swing Detection : No more waiting for swings to finalize! This library continuously identifies the latest swing formation.
3.  Amplitude-Aware : Discover significant swings earlier, even if they haven't reached the standard bar length.
4.  Customizable Visualization : Draw ZigZag on-demand using polylines for a tailored analysis experience.
Stay tuned for more features as this library is being continuously enhanced. For the latest updates, please refer to the release information.
🔵 API
 
// Import this library. Remember to check the latest version of this library and replace the version number below.
import algotraderdev/zigzag/1 as zz
// Initialize the ZigZag instance.
var zz.ZigZag zig = zz.ZigZag.new().init(
  zz.Settings.new(
    swingLen = 5,
    lineColor = color.blue,
    lineStyle = line.style_solid,
    lineWidth = 1))
// Analyze the ZigZag using the latest bar's data.
zig.tick()
// Draw the ZigZag.
if barstate.islast
  zig.draw()
ZigzagLiteLibrary   "ZigzagLite" 
Lighter version of the Zigzag Library. Without indicators and sub-component divisions
 method getPrices(pivots) 
  Gets the array of prices from array of Pivots
  Namespace types: Pivot 
  Parameters:
     pivots (Pivot ) : array array of Pivot objects
  Returns: array array of pivot prices
 method getBars(pivots) 
  Gets the array of bars from array of Pivots
  Namespace types: Pivot 
  Parameters:
     pivots (Pivot ) : array array of Pivot objects
  Returns: array array of pivot bar indices
 method getPoints(pivots) 
  Gets the array of chart.point from array of Pivots
  Namespace types: Pivot 
  Parameters:
     pivots (Pivot ) : array array of Pivot objects
  Returns: array array of pivot points
 method getPoints(this) 
  Namespace types: Zigzag
  Parameters:
     this (Zigzag) 
 method calculate(this, ohlc, ltfHighTime, ltfLowTime) 
  Calculate zigzag based on input values and indicator values
  Namespace types: Zigzag
  Parameters:
     this (Zigzag) : Zigzag object
     ohlc (float ) : Array containing OHLC values. Can also have custom values for which zigzag to be calculated
     ltfHighTime (int) : Used for multi timeframe zigzags when called within request.security. Default value is current timeframe open time.
     ltfLowTime (int) : Used for multi timeframe zigzags when called within request.security. Default value is current timeframe open time.
  Returns: current Zigzag object
 method calculate(this) 
  Calculate zigzag based on properties embedded within Zigzag object
  Namespace types: Zigzag
  Parameters:
     this (Zigzag) : Zigzag object
  Returns: current Zigzag object
 method nextlevel(this) 
  Namespace types: Zigzag
  Parameters:
     this (Zigzag) 
 method clear(this) 
  Clears zigzag drawings array
  Namespace types: ZigzagDrawing 
  Parameters:
     this (ZigzagDrawing ) : array
  Returns: void
 method clear(this) 
  Clears zigzag drawings array
  Namespace types: ZigzagDrawingPL 
  Parameters:
     this (ZigzagDrawingPL ) : array
  Returns: void
 method drawplain(this) 
  draws fresh zigzag based on properties embedded in ZigzagDrawing object without trying to calculate
  Namespace types: ZigzagDrawing
  Parameters:
     this (ZigzagDrawing) : ZigzagDrawing object
  Returns: ZigzagDrawing object
 method drawplain(this) 
  draws fresh zigzag based on properties embedded in ZigzagDrawingPL object without trying to calculate
  Namespace types: ZigzagDrawingPL
  Parameters:
     this (ZigzagDrawingPL) : ZigzagDrawingPL object
  Returns: ZigzagDrawingPL object
 method drawfresh(this, ohlc) 
  draws fresh zigzag based on properties embedded in ZigzagDrawing object
  Namespace types: ZigzagDrawing
  Parameters:
     this (ZigzagDrawing) : ZigzagDrawing object
     ohlc (float ) : values on which the zigzag needs to be calculated and drawn. If not set will use regular OHLC
  Returns: ZigzagDrawing object
 method drawcontinuous(this, ohlc) 
  draws zigzag based on the zigzagmatrix input
  Namespace types: ZigzagDrawing
  Parameters:
     this (ZigzagDrawing) : ZigzagDrawing object
     ohlc (float ) : values on which the zigzag needs to be calculated and drawn. If not set will use regular OHLC
  Returns:  
 PivotCandle 
  PivotCandle represents data of the candle which forms either pivot High or pivot low or both
  Fields:
     _high (series float) : High price of candle forming the pivot
     _low (series float) : Low price of candle forming the pivot
     length (series int) : Pivot length
     pHighBar (series int) : represents number of bar back the pivot High occurred.
     pLowBar (series int) : represents number of bar back the pivot Low occurred.
     pHigh (series float) : Pivot High Price
     pLow (series float) : Pivot Low Price
 Pivot 
  Pivot refers to zigzag pivot. Each pivot can contain various data
  Fields:
     point (chart.point) : pivot point coordinates
     dir (series int) : direction of the pivot. Valid values are 1, -1, 2, -2
     level (series int) : is used for multi level zigzags. For single level, it will always be 0
     ratio (series float) : Price Ratio based on previous two pivots
     sizeRatio (series float) 
 ZigzagFlags 
  Flags required for drawing zigzag. Only used internally in zigzag calculation. Should not set the values explicitly
  Fields:
     newPivot (series bool) : true if the calculation resulted in new pivot
     doublePivot (series bool) : true if the calculation resulted in two pivots on same bar
     updateLastPivot (series bool) : true if new pivot calculated replaces the old one.
 Zigzag 
  Zigzag object which contains whole zigzag calculation parameters and pivots
  Fields:
     length (series int) : Zigzag length. Default value is 5
     numberOfPivots (series int) : max number of pivots to hold in the calculation. Default value is 20
     offset (series int) : Bar offset to be considered for calculation of zigzag. Default is 0 - which means calculation is done based on the latest bar.
     level (series int) : Zigzag calculation level - used in multi level recursive zigzags
     zigzagPivots (Pivot ) : array which holds the last n pivots calculated.
     flags (ZigzagFlags) : ZigzagFlags object which is required for continuous drawing of zigzag lines.
 ZigzagObject 
  Zigzag Drawing Object
  Fields:
     zigzagLine (series line) : Line joining two pivots
     zigzagLabel (series label) : Label which can be used for drawing the values, ratios, directions etc.
 ZigzagProperties 
  Object which holds properties of zigzag drawing. To be used along with ZigzagDrawing
  Fields:
     lineColor (series color) : Zigzag line color. Default is color.blue
     lineWidth (series int) : Zigzag line width. Default is 1
     lineStyle (series string) : Zigzag line style. Default is line.style_solid.
     showLabel (series bool) : If set, the drawing will show labels on each pivot. Default is false
     textColor (series color) : Text color of the labels. Only applicable if showLabel is set to true.
     maxObjects (series int) : Max number of zigzag lines to display. Default is 300
     xloc (series string) : Time/Bar reference to be used for zigzag drawing. Default is Time - xloc.bar_time.
     curved (series bool) : Boolean field to print curved zigzag - used only with polyline implementation
 ZigzagDrawing 
  Object which holds complete zigzag drawing objects and properties.
  Fields:
     zigzag (Zigzag) : Zigzag object which holds the calculations.
     properties (ZigzagProperties) : ZigzagProperties object which is used for setting the display styles of zigzag
     drawings (ZigzagObject ) : array which contains lines and labels of zigzag drawing.
 ZigzagDrawingPL 
  Object which holds complete zigzag drawing objects and properties - polyline version
  Fields:
     zigzag (Zigzag) : Zigzag object which holds the calculations.
     properties (ZigzagProperties) : ZigzagProperties object which is used for setting the display styles of zigzag
     zigzagLabels (label ) 
     zigzagLine (series polyline) : polyline object of zigzag lines
ZigzagLibrary   "Zigzag" 
Zigzag related user defined types. Depends on DrawingTypes library for basic types
 method tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts ZigzagTypes/Pivot object to string representation
  Namespace types: Pivot
  Parameters:
     this (Pivot) : ZigzagTypes/Pivot
     sortKeys (bool) : If set to true, string output is sorted by keys.
     sortOrder (int) : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys (string ) : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of ZigzagTypes/Pivot
 method tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts Array of Pivot objects to string representation
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) : Pivot object array
     sortKeys (bool) : If set to true, string output is sorted by keys.
     sortOrder (int) : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys (string ) : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of Pivot object array
 method tostring(this) 
  Converts ZigzagFlags object to string representation
  Namespace types: ZigzagFlags
  Parameters:
     this (ZigzagFlags) : ZigzagFlags object
  Returns: string representation of ZigzagFlags
 method tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts ZigzagTypes/Zigzag object to string representation
  Namespace types: Zigzag
  Parameters:
     this (Zigzag) : ZigzagTypes/Zigzagobject
     sortKeys (bool) : If set to true, string output is sorted by keys.
     sortOrder (int) : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys (string ) : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of ZigzagTypes/Zigzag
 method calculate(this, ohlc, indicators, indicatorNames) 
  Calculate zigzag based on input values and indicator values
  Namespace types: Zigzag
  Parameters:
     this (Zigzag) : Zigzag object
     ohlc (float ) : Array containing OHLC values. Can also have custom values for which zigzag to be calculated
     indicators (matrix) : Array of indicator values
     indicatorNames (string ) : Array of indicator names for which values are present. Size of indicators array should be equal to that of indicatorNames
  Returns: current Zigzag object
 method calculate(this) 
  Calculate zigzag based on properties embedded within Zigzag object
  Namespace types: Zigzag
  Parameters:
     this (Zigzag) : Zigzag object
  Returns: current Zigzag object
 method nextlevel(this) 
  Calculate Next Level Zigzag based on the current calculated zigzag object
  Namespace types: Zigzag
  Parameters:
     this (Zigzag) : Zigzag object
  Returns: Next Level Zigzag object
 method clear(this) 
  Clears zigzag drawings array
  Namespace types: ZigzagDrawing 
  Parameters:
     this (ZigzagDrawing ) : array
  Returns: void
 method drawplain(this) 
  draws fresh zigzag based on properties embedded in ZigzagDrawing object without trying to calculate
  Namespace types: ZigzagDrawing
  Parameters:
     this (ZigzagDrawing) : ZigzagDrawing object
  Returns: ZigzagDrawing object
 method drawfresh(this, ohlc, indicators, indicatorNames) 
  draws fresh zigzag based on properties embedded in ZigzagDrawing object
  Namespace types: ZigzagDrawing
  Parameters:
     this (ZigzagDrawing) : ZigzagDrawing object
     ohlc (float ) : values on which the zigzag needs to be calculated and drawn. If not set will use regular OHLC
     indicators (matrix) : Array of indicator values
     indicatorNames (string ) : Array of indicator names for which values are present. Size of indicators array should be equal to that of indicatorNames
  Returns: ZigzagDrawing object
 method drawcontinuous(this, ohlc, indicators, indicatorNames) 
  draws zigzag based on the zigzagmatrix input
  Namespace types: ZigzagDrawing
  Parameters:
     this (ZigzagDrawing) : ZigzagDrawing object
     ohlc (float ) : values on which the zigzag needs to be calculated and drawn. If not set will use regular OHLC
     indicators (matrix) : Array of indicator values
     indicatorNames (string ) : Array of indicator names for which values are present. Size of indicators array should be equal to that of indicatorNames
  Returns:  
 method getPrices(pivots) 
  Namespace types: Pivot 
  Parameters:
     pivots (Pivot ) 
 method getBars(pivots) 
  Namespace types: Pivot 
  Parameters:
     pivots (Pivot ) 
 Indicator 
  Indicator is collection of indicator values applied on high, low and close
  Fields:
     indicatorHigh (series float) : Indicator Value applied on High
     indicatorLow (series float) : Indicator Value applied on Low
 PivotCandle 
  PivotCandle represents data of the candle which forms either pivot High or pivot low or both
  Fields:
     _high (series float) : High price of candle forming the pivot
     _low (series float) : Low price of candle forming the pivot
     length (series int) : Pivot length
     pHighBar (series int) : represents number of bar back the pivot High occurred.
     pLowBar (series int) : represents number of bar back the pivot Low occurred.
     pHigh (series float) : Pivot High Price
     pLow (series float) : Pivot Low Price
     indicators (Indicator ) : Array of Indicators - allows to add multiple
 Pivot 
  Pivot refers to zigzag pivot. Each pivot can contain various data
  Fields:
     point (chart.point) : pivot point coordinates
     dir (series int) : direction of the pivot. Valid values are 1, -1, 2, -2
     level (series int) : is used for multi level zigzags. For single level, it will always be 0
     componentIndex (series int) : is the lower level zigzag array index for given pivot. Used only in multi level Zigzag Pivots
     subComponents (series int) : is the number of sub waves per each zigzag wave. Only applicable for multi level zigzags
     microComponents (series int) : is the number of base zigzag components in a zigzag wave
     ratio (series float) : Price Ratio based on previous two pivots
     sizeRatio (series float) 
     subPivots (Pivot ) 
     indicatorNames (string ) : Names of the indicators applied on zigzag
     indicatorValues (float ) : Values of the indicators applied on zigzag
     indicatorRatios (float ) : Ratios of the indicators applied on zigzag based on previous 2 pivots
 ZigzagFlags 
  Flags required for drawing zigzag. Only used internally in zigzag calculation. Should not set the values explicitly
  Fields:
     newPivot (series bool) : true if the calculation resulted in new pivot
     doublePivot (series bool) : true if the calculation resulted in two pivots on same bar
     updateLastPivot (series bool) : true if new pivot calculated replaces the old one.
 Zigzag 
  Zigzag object which contains whole zigzag calculation parameters and pivots
  Fields:
     length (series int) : Zigzag length. Default value is 5
     numberOfPivots (series int) : max number of pivots to hold in the calculation. Default value is 20
     offset (series int) : Bar offset to be considered for calculation of zigzag. Default is 0 - which means calculation is done based on the latest bar.
     level (series int) : Zigzag calculation level - used in multi level recursive zigzags
     zigzagPivots (Pivot ) : array which holds the last n pivots calculated.
     flags (ZigzagFlags) : ZigzagFlags object which is required for continuous drawing of zigzag lines.
 ZigzagObject 
  Zigzag Drawing Object
  Fields:
     zigzagLine (series line) : Line joining two pivots
     zigzagLabel (series label) : Label which can be used for drawing the values, ratios, directions etc.
 ZigzagProperties 
  Object which holds properties of zigzag drawing. To be used along with ZigzagDrawing
  Fields:
     lineColor (series color) : Zigzag line color. Default is color.blue
     lineWidth (series int) : Zigzag line width. Default is 1
     lineStyle (series string) : Zigzag line style. Default is line.style_solid.
     showLabel (series bool) : If set, the drawing will show labels on each pivot. Default is false
     textColor (series color) : Text color of the labels. Only applicable if showLabel is set to true.
     maxObjects (series int) : Max number of zigzag lines to display. Default is 300
     xloc (series string) : Time/Bar reference to be used for zigzag drawing. Default is Time - xloc.bar_time.
 ZigzagDrawing 
  Object which holds complete zigzag drawing objects and properties.
  Fields:
     zigzag (Zigzag) : Zigzag object which holds the calculations.
     properties (ZigzagProperties) : ZigzagProperties object which is used for setting the display styles of zigzag
     drawings (ZigzagObject ) : array which contains lines and labels of zigzag drawing.
ZigLibLibrary   "ZigLib" 
Calculate the points for ZigZag++. 
You can use custom data and resolution for your ZigZag++.
Sample Usage
 
import DevLucem/ZigLib/1 as ZigZag
  = ZigZag.zigzag(low, high)
bgcolor(direction<0? color.rgb(255, 82, 82, 80): color.rgb(0, 230, 119, 80))
line zz = line.new(z1.time, z1.price, z2.time, z2.price, xloc.bar_time, width=3)
if direction==direction 
    line.delete(zz )
 
 zigzag(_low, _high, depth, deviation, backstep) 
        Get current zigzag points and direction
  Parameters:
     _low (float)  
     _high (float) 
     depth (int) 
     deviation (int) 
     backstep (int) 
        Returns  direction, chart point 1 and chart point 2 
PivotLibrary   "Pivot" 
This library helps you store and manage pivots.
 bias(isHigh, isHigher, prevWasHigher) 
  Helper function to calculate bias.
  Parameters:
     isHigh (bool) : (bool)		Wether the pivot is a pivot high or not.
     isHigher (bool) : (bool)		Wether the pivot is a higher pivot or not.
@return  		(bool) 		The bias (true = bullish, false = bearish, na = neutral).
     prevWasHigher (bool) 
 biasToString(bias) 
  Parameters:
     bias (bool) 
 biasToColor(bias, theme) 
  Parameters:
     bias (bool) 
     theme (Theme) 
 nameString(isHigh, isHigher) 
  Parameters:
     isHigh (bool) 
     isHigher (bool) 
 abbrString(isHigh, isHigher) 
  Parameters:
     isHigh (bool) 
     isHigher (bool) 
 tooltipString(y, isHigh, isHigher, bias, theme) 
  Parameters:
     y (float) 
     isHigh (bool) 
     isHigher (bool) 
     bias (bool) 
     theme (Theme) 
 createLabel(x, y, isHigh, isHigher, prevWasHigher, settings) 
  Parameters:
     x (int) 
     y (float) 
     isHigh (bool) 
     isHigher (bool) 
     prevWasHigher (bool) 
     settings (Settings) 
 new(x, y, isHigh, isHigher, settings) 
  Parameters:
     x (int) 
     y (float) 
     isHigh (bool) 
     isHigher (bool) 
     settings (Settings) 
 newArray(size, initialValue) 
  Parameters:
     size (int) 
     initialValue (Pivot) 
 method getFirst(this) 
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) 
 method getLast(this, isHigh) 
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) 
     isHigh (bool) 
 method getLastHigh(this) 
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) 
 method getLastLow(this) 
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) 
 method getPrev(this, numBack, isHigh) 
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) 
     numBack (int) 
     isHigh (bool) 
 method getPrevHigh(this, numBack) 
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) 
     numBack (int) 
 method getPrevLow(this, numBack) 
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) 
     numBack (int) 
 method getText(this) 
  Namespace types: Pivot
  Parameters:
     this (Pivot) 
 method setX(this, value) 
  Namespace types: Pivot
  Parameters:
     this (Pivot) 
     value (int) 
 method setY(this, value) 
  Namespace types: Pivot
  Parameters:
     this (Pivot) 
     value (float) 
 method setXY(this, x, y) 
  Namespace types: Pivot
  Parameters:
     this (Pivot) 
     x (int) 
     y (float) 
 method setBias(this, value) 
  Namespace types: Pivot
  Parameters:
     this (Pivot) 
     value (int) 
 method setColor(this, value) 
  Namespace types: Pivot
  Parameters:
     this (Pivot) 
     value (color) 
 method setText(this, value) 
  Namespace types: Pivot
  Parameters:
     this (Pivot) 
     value (string) 
 method add(this, pivot) 
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) 
     pivot (Pivot) 
 method updateLast(this, y, settings) 
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) 
     y (float) 
     settings (Settings) 
 method update(this, y, isHigh, settings) 
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) 
     y (float) 
     isHigh (bool) 
     settings (Settings) 
 Pivot 
  Stores Pivot data.
  Fields:
     x (series int) 
     y (series float) 
     isHigh (series bool) 
     isHigher (series bool) 
     bias (series bool) 
     lb (series label) 
 Theme 
  Attributes for customizable look and feel.
  Fields:
     size (series string) 
     colorDefault (series color) 
     colorNeutral (series color) 
     colorBullish (series color) 
     colorBearish (series color) 
     colored (series bool) 
     showTooltips (series bool) 
     showTooltipName (series bool) 
     showTooltipValue (series bool) 
     showTooltipBias (series bool) 
 Settings 
  All settings for the pivot.
  Fields:
     theme (Theme)
Absolute ZigZag LibLibrary   "Absolute_ZigZag_Lib" 
This ZigZag Library is a Bit different. Instead of using percentages or looking more than 1 bar left or right, this Zigzag library calculates pivots by just looking at the current bar highs and lows and the ones of one bar earlier. 
This is the most accurate way of calculating pivots and it also eliminates lag. 
The library also features a solution for bars that have both a higher high and a higher low like seen below.
  
You can also use your own colors for the labels and the lines.
  
You can also quickly select a one-colored theme without changing all colors at once
  
 method isHigherHigh(this) 
  Checks if current pivot is a higher high
  Namespace types: Pivot
  Parameters:
     this (Pivot) : (Pivot)         The object to work with.
@return          (bool)          True if the pivot is a higher high, false if not.
 method isLowerHigh(this) 
  Checks if current pivot is a lower high
  Namespace types: Pivot
  Parameters:
     this (Pivot) : (Pivot)         The object to work with.
@return          (bool)          True if the pivot is a lower high, false if not.
 method isHigherLow(this) 
  Checks if current pivot is a higher low
  Namespace types: Pivot
  Parameters:
     this (Pivot) : (Pivot)         The object to work with.
@return          (bool)          True if the pivot is a higher low, false if not.
 method isLowerLow(this) 
  Checks if current pivot is a lower low
  Namespace types: Pivot
  Parameters:
     this (Pivot) : (Pivot)         The object to work with.
@return          (bool)          True if the pivot is a lower low, false if not.
 method getLastPivotHigh(this) 
  Gets the last Pivot High
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) : (array)  The object to work with.
@return          (Pivot)         The latest Pivot High
 method getLastPivotLow(this) 
  Gets the last Pivot Low
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) : (array)  The object to work with.
@return          (Pivot)         The latest Pivot Low
 method prev(this, index) 
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) 
     index (int) 
 method last(this, throwError) 
  Namespace types: Pivot 
  Parameters:
     this (Pivot ) 
     throwError (bool) 
 new(highFirst, theme) 
  Parameters:
     highFirst (bool) 
     theme (Theme) 
 getLowerTimeframePeriod() 
 Theme 
  Used to create a (color) theme to draw Zigzag
  Fields:
     colorDefault (series color) 
     colorNeutral (series color) 
     colorBullish (series color) 
     colorBearish (series color) 
     coloredLines (series bool) 
 Point 
  Used to determine a coordination on the chart
  Fields:
     x (series int) 
     y (series float) 
 Pivot 
  Used to determine pivots on the chart
  Fields:
     point (Point) 
     isHigh (series bool) 
     isHigher (series bool) 
     ln (series line) 
     lb (series label)
PitchforkMethodsLibrary   "PitchforkMethods" 
Methods associated with Pitchfork and Pitchfork Drawing. Depends on the library PitchforkTypes for Pitchfork/PitchforkDrawing objects which in turn use DrawingTypes for basic objects Point/Line/LineProperties. Also depends on DrawingMethods for related methods
 tostring(this) 
  Converts PitchforkTypes/Fork object to string representation
  Parameters:
     this : PitchforkTypes/Fork object
  Returns: string representation of PitchforkTypes/Fork
 tostring(this) 
  Converts Array of PitchforkTypes/Fork object to string representation
  Parameters:
     this : Array of PitchforkTypes/Fork object
  Returns: string representation of PitchforkTypes/Fork array
 tostring(this, sortKeys, sortOrder) 
  Converts PitchforkTypes/PitchforkProperties object to string representation
  Parameters:
     this : PitchforkTypes/PitchforkProperties object
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
  Returns: string representation of PitchforkTypes/PitchforkProperties
 tostring(this, sortKeys, sortOrder) 
  Converts PitchforkTypes/PitchforkDrawingProperties object to string representation
  Parameters:
     this : PitchforkTypes/PitchforkDrawingProperties object
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
  Returns: string representation of PitchforkTypes/PitchforkDrawingProperties
 tostring(this, sortKeys, sortOrder) 
  Converts PitchforkTypes/Pitchfork object to string representation
  Parameters:
     this : PitchforkTypes/Pitchfork object
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
  Returns: string representation of PitchforkTypes/Pitchfork
 createDrawing(this) 
  Creates PitchforkTypes/PitchforkDrawing from PitchforkTypes/Pitchfork object
  Parameters:
     this : PitchforkTypes/Pitchfork object
  Returns: PitchforkTypes/PitchforkDrawing object created
 createDrawing(this) 
  Creates PitchforkTypes/PitchforkDrawing array from PitchforkTypes/Pitchfork array of objects
  Parameters:
     this : array of PitchforkTypes/Pitchfork object
  Returns: array of PitchforkTypes/PitchforkDrawing object created
 draw(this) 
  draws from PitchforkTypes/PitchforkDrawing object
  Parameters:
     this : PitchforkTypes/PitchforkDrawing object
  Returns: PitchforkTypes/PitchforkDrawing object drawn
 delete(this) 
  deletes PitchforkTypes/PitchforkDrawing object
  Parameters:
     this : PitchforkTypes/PitchforkDrawing object
  Returns: PitchforkTypes/PitchforkDrawing object deleted
 delete(this) 
  deletes underlying drawing of PitchforkTypes/Pitchfork object
  Parameters:
     this : PitchforkTypes/Pitchfork object
  Returns: PitchforkTypes/Pitchfork object deleted
 delete(this) 
  deletes array of PitchforkTypes/PitchforkDrawing objects
  Parameters:
     this : Array of PitchforkTypes/PitchforkDrawing object
  Returns: Array of PitchforkTypes/PitchforkDrawing object deleted
 delete(this) 
  deletes underlying drawing in array of PitchforkTypes/Pitchfork objects
  Parameters:
     this : Array of PitchforkTypes/Pitchfork object
  Returns: Array of PitchforkTypes/Pitchfork object deleted
 clear(this) 
  deletes array of PitchforkTypes/PitchforkDrawing objects and clears the array
  Parameters:
     this : Array of PitchforkTypes/PitchforkDrawing object
  Returns: void
 clear(this) 
  deletes array of PitchforkTypes/Pitchfork objects and clears the array
  Parameters:
     this : Array of Pitchfork/Pitchfork object
  Returns: void
PitchforkTypesLibrary   "PitchforkTypes" 
User Defined Types to be used for Pitchfork and Drawing elements of Pitchfork. Depends on DrawingTypes for Point, Line, and LineProperties objects
 PitchforkDrawingProperties 
  Pitchfork Drawing Properties object
  Fields:
     extend : If set to true, forks are extended towards right. Default is true
     fill : Fill forklines with transparent color. Default is true
     fillTransparency : Transparency at which fills are made. Only considered when fill is set. Default is 80
     forceCommonColor : Force use of common color for forks and fills. Default is false
     commonColor : common fill color. Used only if ratio specific fill colors are not available or if forceCommonColor is set to true.
 PitchforkDrawing 
  Pitchfork drawing components
  Fields:
     medianLine : Median line of the pitchfork
     baseLine : Base line of the pitchfork
     forkLines : fork lines of the pitchfork
     linefills : Linefills between forks
 Fork 
  Fork object property
  Fields:
     ratio : Fork ratio
     forkColor : color of fork. Default is blue
     include : flag to include the fork in drawing. Default is true
 PitchforkProperties 
  Pitchfork Properties
  Fields:
     forks : Array of Fork objects
     type : Pitchfork type. Supported values are "regular", "schiff", "mschiff", Default is regular
     inside : Flag to identify if to draw inside fork. If set to true, inside fork will be drawn
 Pitchfork 
  Pitchfork object
  Fields:
     a : Pivot Point A of pitchfork
     b : Pivot Point B of pitchfork
     c : Pivot Point C of pitchfork
     properties : PitchforkProperties object which determines type and composition of pitchfork
     dProperties : Drawing properties for pitchfork
     lProperties : Common line properties for Pitchfork lines
     drawing : PitchforkDrawing object
ZigzagMethodsLibrary   "ZigzagMethods" 
Object oriented implementation of Zigzag methods. Please refer to ZigzagTypes library for User defined types used in this library
 tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts ZigzagTypes/Pivot object to string representation
  Parameters:
     this : ZigzagTypes/Pivot
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of ZigzagTypes/Pivot
 tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts Array of Pivot objects to string representation
  Parameters:
     this : Pivot object array
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of Pivot object array
 tostring(this) 
  Converts ZigzagFlags object to string representation
  Parameters:
     this : ZigzagFlags object
  Returns: string representation of ZigzagFlags
 tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts ZigzagTypes/Zigzag object to string representation
  Parameters:
     this : ZigzagTypes/Zigzagobject
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of ZigzagTypes/Zigzag
 calculate(this, ohlc, indicators, indicatorNames) 
  Calculate zigzag based on input values and indicator values
  Parameters:
     this : Zigzag object
     ohlc : Array containing OHLC values. Can also have custom values for which zigzag to be calculated
     indicators : Array of indicator values
     indicatorNames : Array of indicator names for which values are present. Size of indicators array should be equal to that of indicatorNames
  Returns: current Zigzag object
 calculate(this) 
  Calculate zigzag based on properties embedded within Zigzag object
  Parameters:
     this : Zigzag object
  Returns: current Zigzag object
 nextlevel(this) 
  Calculate Next Level Zigzag based on the current calculated zigzag object
  Parameters:
     this : Zigzag object
  Returns: Next Level Zigzag object
 clear(this) 
  Clears zigzag drawings array
  Parameters:
     this : array
  Returns: void
 drawfresh(this) 
  draws fresh zigzag based on properties embedded in ZigzagDrawing object
  Parameters:
     this : ZigzagDrawing object
  Returns: ZigzagDrawing object
 drawcontinuous(this) 
  draws zigzag based on the zigzagmatrix input
  Parameters:
     this : ZigzagDrawing object
  Returns: 
ZigzagTypesLibrary   "ZigzagTypes" 
Zigzag related user defined types. Depends on DrawingTypes library for basic types
 Indicator 
  Indicator is collection of indicator values applied on high, low and close
  Fields:
     indicatorHigh : Indicator Value applied on High
     indicatorLow : Indicator Value applied on Low
 PivotCandle 
  PivotCandle represents data of the candle which forms either pivot High or pivot low or both
  Fields:
     _high : High price of candle forming the pivot
     _low : Low price of candle forming the pivot
     length : Pivot length
     pHighBar : represents number of bar back the pivot High occurred.
     pLowBar : represents number of bar back the pivot Low occurred.
     pHigh : Pivot High Price
     pLow : Pivot Low Price
     indicators : Array of Indicators - allows to add multiple
 Pivot 
  Pivot refers to zigzag pivot. Each pivot can contain various data
  Fields:
     point : pivot point coordinates
     dir : direction of the pivot. Valid values are 1, -1, 2, -2
     level : is used for multi level zigzags. For single level, it will always be 0
     ratio : Price Ratio based on previous two pivots
     indicatorNames : Names of the indicators applied on zigzag
     indicatorValues : Values of the indicators applied on zigzag
     indicatorRatios : Ratios of the indicators applied on zigzag based on previous 2 pivots
 ZigzagFlags 
  Flags required for drawing zigzag. Only used internally in zigzag calculation. Should not set the values explicitly
  Fields:
     newPivot : true if the calculation resulted in new pivot
     doublePivot : true if the calculation resulted in two pivots on same bar
     updateLastPivot : true if new pivot calculated replaces the old one.
 Zigzag 
  Zigzag object which contains whole zigzag calculation parameters and pivots
  Fields:
     length : Zigzag length. Default value is 5
     numberOfPivots : max number of pivots to hold in the calculation. Default value is 20
     offset : Bar offset to be considered for calculation of zigzag. Default is 0 - which means calculation is done based on the latest bar.
     level : Zigzag calculation level - used in multi level recursive zigzags
     zigzagPivots : array which holds the last n pivots calculated. 
     flags : ZigzagFlags object which is required for continuous drawing of zigzag lines.
 ZigzagObject 
  Zigzag Drawing Object
  Fields:
     zigzagLine : Line joining two pivots
     zigzagLabel : Label which can be used for drawing the values, ratios, directions etc.
 ZigzagProperties 
  Object which holds properties of zigzag drawing. To be used along with ZigzagDrawing
  Fields:
     lineColor : Zigzag line color. Default is color.blue
     lineWidth : Zigzag line width. Default is 1
     lineStyle : Zigzag line style. Default is line.style_solid. 
     showLabel : If set, the drawing will show labels on each pivot. Default is false
     textColor : Text color of the labels. Only applicable if showLabel is set to true.
     maxObjects : Max number of zigzag lines to display. Default is 300
     xloc : Time/Bar reference to be used for zigzag drawing. Default is Time - xloc.bar_time.
 ZigzagDrawing 
  Object which holds complete zigzag drawing objects and properties.
  Fields:
     properties : ZigzagProperties object which is used for setting the display styles of zigzag
     drawings : array which contains lines and labels of zigzag drawing.
     zigzag : Zigzag object which holds the calculations.
DrawingMethodsLibrary   "DrawingMethods" 
 tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts DrawingTypes/Point object to string representation
  Parameters:
     this : DrawingTypes/Point object
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/Point
 tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts DrawingTypes/LineProperties object to string representation
  Parameters:
     this : DrawingTypes/LineProperties object
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/LineProperties
 tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts DrawingTypes/Line object to string representation
  Parameters:
     this : DrawingTypes/Line object
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/Line
 tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts DrawingTypes/LabelProperties object to string representation
  Parameters:
     this : DrawingTypes/LabelProperties object
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/LabelProperties
 tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts DrawingTypes/Label object to string representation
  Parameters:
     this : DrawingTypes/Label object
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/Label
 tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts DrawingTypes/Linefill object to string representation
  Parameters:
     this : DrawingTypes/Linefill object
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/Linefill
 tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts DrawingTypes/BoxProperties object to string representation
  Parameters:
     this : DrawingTypes/BoxProperties object
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/BoxProperties
 tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts DrawingTypes/BoxText object to string representation
  Parameters:
     this : DrawingTypes/BoxText object
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/BoxText
 tostring(this, sortKeys, sortOrder, includeKeys) 
  Converts DrawingTypes/Box object to string representation
  Parameters:
     this : DrawingTypes/Box object
     sortKeys : If set to true, string output is sorted by keys.
     sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
     includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/Box
 delete(this) 
  Deletes line from DrawingTypes/Line object
  Parameters:
     this : DrawingTypes/Line object
  Returns: Line object deleted
 delete(this) 
  Deletes label from DrawingTypes/Label object
  Parameters:
     this : DrawingTypes/Label object
  Returns: Label object deleted
 delete(this) 
  Deletes Linefill from DrawingTypes/Linefill object
  Parameters:
     this : DrawingTypes/Linefill object
  Returns: Linefill object deleted
 delete(this) 
  Deletes box from DrawingTypes/Box object
  Parameters:
     this : DrawingTypes/Box object
  Returns: DrawingTypes/Box object deleted
 delete(this) 
  Deletes lines from array of DrawingTypes/Line objects
  Parameters:
     this : Array of DrawingTypes/Line objects
  Returns: Array of DrawingTypes/Line objects
 delete(this) 
  Deletes labels from array of DrawingTypes/Label objects
  Parameters:
     this : Array of DrawingTypes/Label objects
  Returns: Array of DrawingTypes/Label objects
 delete(this) 
  Deletes linefill from array of DrawingTypes/Linefill objects
  Parameters:
     this : Array of DrawingTypes/Linefill objects
  Returns: Array of DrawingTypes/Linefill objects
 delete(this) 
  Deletes boxes from array of DrawingTypes/Box objects
  Parameters:
     this : Array of DrawingTypes/Box objects
  Returns: Array of DrawingTypes/Box objects
 clear(this) 
  clear items from array of DrawingTypes/Line while deleting underlying objects
  Parameters:
     this : array
  Returns: void
 clear(this) 
  clear items from array of DrawingTypes/Label while deleting underlying objects
  Parameters:
     this : array
  Returns: void
 clear(this) 
  clear items from array of DrawingTypes/Linefill while deleting underlying objects
  Parameters:
     this : array
  Returns: void
 clear(this) 
  clear items from array of DrawingTypes/Box while deleting underlying objects
  Parameters:
     this : array
  Returns: void
 draw(this) 
  Creates line from DrawingTypes/Line object
  Parameters:
     this : DrawingTypes/Line object
  Returns: line created from DrawingTypes/Line object
 draw(this) 
  Creates lines from array of DrawingTypes/Line objects
  Parameters:
     this : Array of DrawingTypes/Line objects
  Returns: Array of DrawingTypes/Line objects
 draw(this) 
  Creates label from DrawingTypes/Label object
  Parameters:
     this : DrawingTypes/Label object
  Returns: label created from DrawingTypes/Label object
 draw(this) 
  Creates labels from array of DrawingTypes/Label objects
  Parameters:
     this : Array of DrawingTypes/Label objects
  Returns: Array of DrawingTypes/Label objects
 draw(this) 
  Creates linefill object from DrawingTypes/Linefill
  Parameters:
     this : DrawingTypes/Linefill objects
  Returns: linefill object created
 draw(this) 
  Creates linefill objects from array of DrawingTypes/Linefill objects
  Parameters:
     this : Array of DrawingTypes/Linefill objects
  Returns: Array of DrawingTypes/Linefill used for creating linefills
 draw(this) 
  Creates box from DrawingTypes/Box object
  Parameters:
     this : DrawingTypes/Box object
  Returns: box created from DrawingTypes/Box object
 draw(this) 
  Creates labels from array of DrawingTypes/Label objects
  Parameters:
     this : Array of DrawingTypes/Label objects
  Returns: Array of DrawingTypes/Label objects
 createLabel(this, lblText, tooltip, properties) 
  Creates DrawingTypes/Label object from DrawingTypes/Point
  Parameters:
     this : DrawingTypes/Point object
     lblText : Label text
     tooltip : Tooltip text. Default is na
     properties : DrawingTypes/LabelProperties object. Default is na - meaning default values are used.
  Returns: DrawingTypes/Label object
 createLine(this, other, properties) 
  Creates DrawingTypes/Line object from one DrawingTypes/Point to other
  Parameters:
     this : First DrawingTypes/Point object
     other : Second DrawingTypes/Point object
     properties : DrawingTypes/LineProperties object. Default set to na - meaning default values are used.
  Returns: DrawingTypes/Line object
 createLinefill(this, other, fillColor, transparency) 
  Creates DrawingTypes/Linefill object from DrawingTypes/Line object to other DrawingTypes/Line object
  Parameters:
     this : First DrawingTypes/Line object
     other : Other DrawingTypes/Line object
     fillColor : fill color of linefill. Default is color.blue
     transparency : fill transparency for linefill. Default is 80
  Returns: Array of DrawingTypes/Linefill object
 createBox(this, other, properties, textProperties) 
  Creates DrawingTypes/Box object from one DrawingTypes/Point to other
  Parameters:
     this : First DrawingTypes/Point object
     other : Second DrawingTypes/Point object
     properties : DrawingTypes/BoxProperties object. Default set to na - meaning default values are used.
     textProperties : DrawingTypes/BoxText object. Default is na - meaning no text will be drawn
  Returns: DrawingTypes/Box object
 createBox(this, properties, textProperties) 
  Creates DrawingTypes/Box object from DrawingTypes/Line as diagonal line
  Parameters:
     this : Diagonal DrawingTypes/PoLineint object
     properties : DrawingTypes/BoxProperties object. Default set to na - meaning default values are used.
     textProperties : DrawingTypes/BoxText object. Default is na - meaning no text will be drawn
  Returns: DrawingTypes/Box object
DrawingTypesLibrary   "DrawingTypes" 
User Defined Types for basic drawing structure. Other types and methods will be built on these.
 Point 
  Point refers to point on chart
  Fields:
     price : pivot price
     bar : pivot bar
     bartime : pivot bar time
 LineProperties 
  Properties of line object
  Fields:
     xloc : X Reference - can be either xloc.bar_index or xloc.bar_time. Default is xloc.bar_index
     extend : Property which sets line to extend towards either right or left or both. Valid values are extend.right, extend.left, extend.both, extend.none. Default is extend.none
     color : Line color
     style : Line style, valid values are line.style_solid, line.style_dashed, line.style_dotted, line.style_arrow_left, line.style_arrow_right, line.style_arrow_both. Default is line.style_solid
     width : Line width. Default is 1
 Line 
  Line object created from points
  Fields:
     start : Starting point of the line
     end : Ending point of the line
     properties : LineProperties object which defines the style of line
     object : Derived line object
 LabelProperties 
  Properties of label object
  Fields:
     xloc : X Reference - can be either xloc.bar_index or xloc.bar_time. Default is xloc.bar_index
     yloc : Y reference - can be yloc.price, yloc.abovebar, yloc.belowbar. Default is yloc.price
     color : Label fill color
     style : Label style as defined in www.tradingview.com Default is label.style_none
     textcolor : text color. Default is color.black
     size : Label text size. Default is size.normal. Other values are size.auto, size.tiny, size.small, size.normal, size.large, size.huge
     textalign : Label text alignment. Default if text.align_center. Other allowed values - text.align_right, text.align_left, text.align_top, text.align_bottom
     text_font_family : The font family of the text. Default value is font.family_default. Other available option is font.family_monospace
 Label 
  Label object
  Fields:
     point : Point where label is drawn
     lblText : label text
     tooltip : Tooltip text. Default is na
     properties : LabelProperties object
     object : Pine label object
 Linefill 
  Linefill object
  Fields:
     line1 : First line to create linefill
     line2 : Second line to create linefill
     fillColor : Fill color
     transparency : Fill transparency range from 0 to 100
     object : linefill object created from wrapper
 BoxProperties 
  BoxProperties object
  Fields:
     border_color : Box border color. Default is color.blue
     bgcolor : box background color
     border_width : Box border width. Default is 1
     border_style : Box border style. Default is line.style_solid
     extend : Extend property of box. default is extend.none
     xloc : defines if drawing needs to be done based on bar index or time. default is xloc.bar_index
 BoxText 
  Box Text properties.
  Fields:
     boxText : Text to be printed on the box
     text_size : Text size. Default is size.auto
     text_color : Box text color. Default is color.yellow. 
     text_halign : horizontal align style - default is text.align_center
     text_valign : vertical align style - default is text.align_center
     text_wrap : text wrap style - default is text.wrap_auto
     text_font_family : Text font. Default is
 Box 
  Box object
  Fields:
     p1 : Diagonal point one
     p2 : Diagonal point two
     properties : Box properties
     textProperties : Box text properties
     object : Box object created
rzigzagLibrary   "rzigzag" 
Recursive Zigzag Using Matrix allows to create zigzags recursively on multiple levels. After bit of consideration, decided to make this public.
 zigzag(length, ohlc, numberOfPivots, offset) 
  calculates plain zigzag based on input
  Parameters:
     length : Zigzag Length
     ohlc : Array containing ohlc values. Can also contain custom series
     numberOfPivots : Number of max pivots to be returned
     offset : Offset from current bar. Can be used for calculations based on confirmed bars
  Returns:  
 nextlevel(zigzagmatrix, numberOfPivots) 
  calculates next level zigzag based on present zigzag coordinates
  Parameters:
     zigzagmatrix : Matrix containing zigzag pivots, bars, bar time, direction and level
     numberOfPivots : Number of max pivots to be returned
  Returns: matrix zigzagmatrix
 draw(zigzagmatrix, newPivot, doublePivot, lineColor, lineWidth, lineStyle, showLabel, xloc) 
  draws zigzag based on the zigzagmatrix input
  Parameters:
     zigzagmatrix : Matrix containing zigzag pivots, bars, bar time, direction and level
     newPivot : Flag indicating there is update in the pivots
     doublePivot : Flag containing there is double pivot update on same bar
     lineColor : Zigzag line color
     lineWidth : Zigzag line width
     lineStyle : Zigzag line style
     showLabel : Flag to indicate display pivot labels
     xloc : xloc preference for drawing lines/labels
  Returns:  
 draw(length, ohlc, numberOfPivots, offset, lineColor, lineWidth, lineStyle, showLabel, xloc) 
  calculates and draws zigzag based on zigzag length and source input
  Parameters:
     length : Zigzag Length
     ohlc : Array containing ohlc values. Can also contain custom series
     numberOfPivots : Number of max pivots to be returned
     offset : Offset from current bar. Can be used for calculations based on confirmed bars
     lineColor : Zigzag line color
     lineWidth : Zigzag line width
     lineStyle : Zigzag line style
     showLabel : Flag to indicate display pivot labels
     xloc : xloc preference for drawing lines/labels
  Returns:  
 drawfresh(zigzagmatrix, zigzaglines, zigzaglabels, lineColor, lineWidth, lineStyle, showLabel, xloc) 
  draws fresh zigzag for all pivots in the input matrix.
  Parameters:
     zigzagmatrix : Matrix containing zigzag pivots, bars, bar time, direction and level
     zigzaglines : array to which all newly created lines will be added
     zigzaglabels : array to which all newly created lables will be added
     lineColor : Zigzag line color
     lineWidth : Zigzag line width
     lineStyle : Zigzag line style
     showLabel : Flag to indicate display pivot labels
     xloc : xloc preference for drawing lines/labels
  Returns: 
PivotsLibrary   "Pivots" 
This Library focuses in functions related to pivot highs and lows and some of their applications (i.e. divergences, zigzag, harmonics, support and resistance...)
 pivots(srcH, srcL, length)  Delivers series of pivot highs, lows and zigzag.
  Parameters:
     srcH : Source series to look for pivot highs. Stricter applications might source from 'close' prices. Oscillators are also another possible source to look for pivot highs and lows. By default 'high'
     srcL : Source series to look for pivot lows. By default 'low'
     length : This value represents the minimum number of candles between pivots. The lower the number, the more detailed the pivot profile. The higher the number, the more relevant the pivots. By default 10
  Returns:  
 zigzagArray(pivotHigh, pivotLow)  Delivers a Zigzag series based on alternating pivots. Ocasionally this line could paint a few consecutive lows or highs without alternating. That happens because it's finding a few consecutive Higher Highs or Lower Lows. If to use lines entities instead of series, that could be easily avoided. But in this one, I'm more interested outputting series rather than painting/deleting line entities.
  Parameters:
     pivotHigh : Pivot high series
     pivotLow : Pivot low series
  Returns:  
 zigzagLine(srcH, srcL, colorLine, widthLine)  Delivers a Zigzag based on line entities.
  Parameters:
     srcH : Source series to look for pivot highs. Stricter applications might source from 'close' prices. Oscillators are also another possible source to look for pivot highs and lows. By default 'high'
     srcL : Source series to look for pivot lows. By default 'low'
     colorLine : Color of the Zigzag Line. By default Fuchsia
     widthLine : Width of the Zigzag Line. By default 4
  Returns: Zigzag printed on screen
 divergence(h2, l2, h1, l1, length)  Calculates divergences between 2 series
  Parameters:
     h2 : Series in which to locate divs: Highs
     l2 : Series in which to locate divs: Lows
     h1 : Series in which to locate pivots: Highs. By default high
     l1 : Series in which to locate pivots: Lows. By default low
     length : Length used to calculate Pivots: By default 10
  Returns: 
FunctionZigZagMultipleMethodsLibrary   "FunctionZigZagMultipleMethods" 
ZigZag Multiple Methods.
 method(idx)  Helper methods enumeration.
  Parameters:
     idx : int, index of method, range 0 to 4.
  Returns: string
 function(method, value_x, value_y)  Multiple method ZigZag.
  Parameters:
     method : string, default='(MANUAL) Percent price move over X * Y', method for zigzag.
     value_x : float, x value in method.
     value_y : float, y value in method.
  Returns: tuple with:
zigzag float
direction
reverse_line float
realtimeofpivot int
supertrendHere is an extensive library on different variations of supertrend. 
Library   "supertrend" 
supertrend : Library dedicated to different variations of supertrend
 supertrend_atr(length, multiplier, atrMaType, source, highSource, lowSource, waitForClose, delayed)  supertrend_atr: Simple supertrend based on atr but also takes into consideration of custom MA Type, sources
	Parameters:
 	 length : : ATR Length
	 multiplier : : ATR Multiplier
	 atrMaType : : Moving Average type for ATR calculation. This can be sma, ema, hma, rma, wma, vwma, swma
	 source : : Default is close. Can Chose custom source
	 highSource : : Default is high. Can also use close price for both high and low source
	 lowSource : : Default is low. Can also use close price for both high and low source
	 waitForClose : : Considers source for direction change crossover if checked. Else, uses highSource and lowSource.
	 delayed : : if set to true lags supertrend atr stop based on target levels. 
	Returns: dir : Supertrend direction
supertrend : BuyStop if direction is 1 else SellStop
 supertrend_bands(bandType, maType, length, multiplier, source, highSource, lowSource, waitForClose, useTrueRange, useAlternateSource, alternateSource, sticky)  supertrend_bands: Simple supertrend based on atr but also takes into consideration of custom MA Type, sources
	Parameters:
 	 bandType : : Type of band used - can be bb, kc or dc
	 maType : : Moving Average type for Bands. This can be sma, ema, hma, rma, wma, vwma, swma
	 length : : Band Length
	 multiplier : : Std deviation or ATR multiplier for Bollinger Bands and Keltner Channel
	 source : : Default is close. Can Chose custom source
	 highSource : : Default is high. Can also use close price for both high and low source
	 lowSource : : Default is low. Can also use close price for both high and low source
	 waitForClose : : Considers source for direction change crossover if checked. Else, uses highSource and lowSource.
	 useTrueRange : : Used for Keltner channel. If set to false, then high-low is used as range instead of true range
	 useAlternateSource : - Custom source is used for Donchian Chanbel only if useAlternateSource is set to true
	 alternateSource : - Custom source for Donchian channel
	 sticky : : if set to true borders change only when price is beyond borders. 
	Returns: dir : Supertrend direction
supertrend : BuyStop if direction is 1 else SellStop
 supertrend_zigzag(length, history, useAlternateSource, alternateSource, source, highSource, lowSource, waitForClose, atrlength, multiplier, atrMaType)  supertrend_zigzag: Zigzag pivot based supertrend
	Parameters:
 	 length : : Zigzag Length
	 history : : number of historical pivots to consider
	 useAlternateSource : - Custom source is used for Zigzag only if useAlternateSource is set to true
	 alternateSource : - Custom source for Zigzag
	 source : : Default is close. Can Chose custom source
	 highSource : : Default is high. Can also use close price for both high and low source
	 lowSource : : Default is low. Can also use close price for both high and low source
	 waitForClose : : Considers source for direction change crossover if checked. Else, uses highSource and lowSource.
	 atrlength : : ATR Length
	 multiplier : : ATR Multiplier
	 atrMaType : : Moving Average type for ATR calculation. This can be sma, ema, hma, rma, wma, vwma, swma 
	Returns: dir : Supertrend direction
supertrend : BuyStop if direction is 1 else SellStop






















