PINE LIBRARY

Zigzag

Cập nhật
Library "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<float>): 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<ZigzagDrawing>
  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<float>): 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<float>): 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: [array<line> zigzaglines, array<label> zigzaglabels]

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<Pivot> 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<ZigzagObject> which contains lines and labels of zigzag drawing.
Phát hành các Ghi chú
v2

Added:
method getPoints(this)
  Namespace types: Zigzag
  Parameters:
    this (Zigzag)

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

Updated:
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

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
Phát hành các Ghi chú
v3

Updated:
method tostring(this, sortKeys, sortOrder, includeKeys)
  Namespace types: Zigzag
  Parameters:
    this (Zigzag)
    sortKeys (bool)
    sortOrder (int)
    includeKeys (string[])

method getPrices(pivots)
  Gets the array of prices from array of Pivots
  Namespace types: Pivot[]
  Parameters:
    pivots (Pivot[]): array<Pivot> array of Pivot objects
  Returns: array<float> array of pivot prices

method getBars(pivots)
  Gets the array of bars from array of Pivots
  Namespace types: Pivot[]
  Parameters:
    pivots (Pivot[]): array<Pivot> array of Pivot objects
  Returns: array<int> array of pivot bar indices
Phát hành các Ghi chú
v4
Phát hành các Ghi chú
v5

Updated:
method clear(this)
  Clears zigzag drawings array
  Namespace types: ZigzagDrawingPL[]
  Parameters:
    this (ZigzagDrawingPL[]): array<ZigzagDrawingPL>
  Returns: void
Phát hành các Ghi chú
v6
Phát hành các Ghi chú
v7

Updated:
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): Ratio of size beteen current zigzag wave and the last zigzag wave in the same direction.
    barRatio (series float): Bar Ratio based on previous two pivots
    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
Phát hành các Ghi chú
v8

Updated:
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): Ratio of size beteen current zigzag wave and the last zigzag wave in the same direction.
    barRatio (series float): Bar Ratio based on previous two pivots
    subPivots (array<Pivot>): direct sub pivots of multi level zigzag
    micropivots (array<Pivot>): all micropivots of the the multi level zigzag
    indicatorNames (array<string>): Names of the indicators applied on zigzag
    indicatorValues (array<float>): Values of the indicators applied on zigzag
    indicatorRatios (array<float>): Ratios of the indicators applied on zigzag based on previous 2 pivots
Phát hành các Ghi chú
v9
Phát hành các Ghi chú
v10
arrayshewhomustnotbenamedMarket GeometrytechindicatortrendoscopeZigzag

Thư viện Pine

Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ.

Thông báo miễn trừ trách nhiệm