niquedegraaff

Absolute ZigZag Lib

niquedegraaff Cập nhật   
Library "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<Pivot>) 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<Pivot>) 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)
Phát hành các Ghi chú:
v2: Fixes bug that would draw wrong color
Phát hành các Ghi chú:
v3 | Minor (commenting) updates and fixes in script. The new() function now returns the pivots array.
Phát hành các Ghi chú:
v4 | Major overhaul of functions and added extra functions to get latest and previous pivot high / low

Added:
method first(this)
  Gets the first Pivot
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
@return (Pivot) The first Pivot in the array or NA if not available.

method getHigh(this, prev)
  Gets the latest Pivot High based on prev number Pivot high back. Default the latest
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
    prev (int): (int) Number of prev pivot highs back. (1 = latest, 1 < is previous ones).
@return (Pivot) The latest Pivot High or NA if not available.

method getLastHigh(this)
  Gets the latest pivot high
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
@return (Pivot) The latest Pivot high in the array

method getPrevHigh(this)
  Gets the previous pivot high
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
@return (Pivot) The previous Pivot high in the array or NA if not available

method getLow(this, prev)
  Gets the Pivot Low
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
    prev (int)

method getLastLow(this)
  Gets the latest pivot low
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
@return (Pivot) The latest Pivot low in the array or NA if not available

method getPrevLow(this)
  Gets the previous pivot low
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
@return (Pivot) The previous Pivot low in the array or NA if not available

Updated:
method last(this)
  Gets previous Pivot
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
@return (Pivot) The last Pivot in the array or NA if not available.

method prev(this)
  Gets previous Pivot
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
@return (Pivot) The previous Pivot or NA if not available.

Removed:
method getLastPivotHigh(this)
  Gets the last Pivot High

method getLastPivotLow(this)
  Gets the last Pivot Low
Phát hành các Ghi chú:
v5 | In this update, I've added new features and changed some array methods to avoid confusion. The library no longer overrides the get(), last(), first() functions for the array object.
Added new Features:
  • Now let's you select custom source
  • Now keeps track of current close price of pivot
  • Can disable/enable the feature to show close price info of pivots

Added:
method getFirst(this)
  Gets the first Pivot
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
@return (Pivot) The first Pivot in the array or NA if not available.

method getLast(this)
  Gets previous Pivot
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
@return (Pivot) The last Pivot in the array or NA if not available.

method getPrev(this, index)
  Gets previous Pivot by index number.
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
    index (int): (int) The index number. (optional, default is 1)
@return (Pivot) The previous Pivot or NA if not available.

method barIsPivot(pivots)
  Namespace types: Pivot
  Parameters:
    pivots (Pivot)

Updated:
method getLastLow(this)
  Gets the latest pivot low
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
@return (Pivot) The latest Pivot low in the array or NA if not available

method getPrevLow(this)
  Gets the previous pivot low
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
@return (Pivot) The previous Pivot low in the array or NA if not available

new(sourceHigh, sourceLow, highFirst, theme)
  Parameters:
    sourceHigh (float)
    sourceLow (float)
    highFirst (bool)
    theme (Theme)

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)
    showCloseInfo (series bool)

Pivot
  Used to determine pivots on the chart
  Fields:
    point (Point)
    isHigh (series bool)
    isHigher (series bool)
    close (series float)
    closeAbovePrevPivot (series bool)
    closeAbovePrevPivotClose (series bool)
    ln (series line)
    lb (series label)

Removed:
method first(this)
  Gets the first Pivot

method last(this)
  Gets previous Pivot

method prev(this)
  Gets previous Pivot
Phát hành các Ghi chú:
v6 | Fixed a bug at pivot lows, that would draw lines from high instead of low
Phát hành các Ghi chú:
v7 | This update brings:
  • Enable/disable enable features
  • Tooltips with all available data for all pivots. Great for feedback on mouse-hover. You can customize the what is shown or hidden.


Added:
method isAtCurrentBar(this)
  Checks if the current pivot is at the current bar
  Namespace types: Pivot
  Parameters:
    this (Pivot): (Pivot) The object to work with.
@return (bool) Wether the current pivot is at the current bar or not.

Source
  The source to use
  Fields:
    high (series float)
    low (series float)
    priority (series string)

Features
  Features to enable
  Fields:
    closeBreaksClose (series bool)
    closeBreaksPivot (series bool)

Tooltips
  Tooltips to show
  Fields:
    name (series bool)
    price (series bool)
    close (series bool)
    closeBreaksClose (series bool)
    closeBreaksPivot (series bool)

Settings
  All settings for the indicator
  Fields:
    source (Source)
    features (Features)
    theme (Theme)

Updated:
method getLast(this)
  Gets the latest Pivot
  Namespace types: Pivot
  Parameters:
    this (Pivot): (array) The object to work with.
@return (Pivot) The last Pivot in the array or NA if not available.

new(customSettings)
  Creates a new ZigZag Instance
  Parameters:
    customSettings (Settings): (Settings) The settings for this instance.

getLowerTimeframePeriod()
  Helper function to generate a lower timeframe period (string) for current timeframe period.
You can use this on conjuction with request.security_lower_tf() to figure out if current high of
of this bar was created before the low of this bar.
@return (string) Timeframe period for lower timeframe.

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)
    showCloseInfo (series bool)
    showTooltips (series bool)
    tooltips (Tooltips)

Pivot
  Used to determine pivots on the chart.
  Fields:
    point (Point)
    isHigh (series bool)
    isHigher (series bool)
    name (series string)
    abbr (series string)
    close (series float)
    comulativeVolume (series float)
    closeBreaksPivot (series bool)
    closeBreaksClose (series bool)
    isLast (series bool)
    ln (series line)
    lb (series label)
Phát hành các Ghi chú:
v8 | You can now customize the size of the pivot text and the thickness of the lines.

Updated:
Theme
  Used to create a (color) theme to draw Zigzag
  Fields:
    colorDefault (series color)
    colorNeutral (series color)
    colorBullish (series color)
    colorBearish (series color)
    labelSize (series string)
    lineWidth (series int)
    coloredLines (series bool)
    showCloseInfo (series bool)
    showTooltips (series bool)
    tooltips (Tooltips)
Phát hành các Ghi chú:
v9 | Fixed bug where pivot lows checked close breaks close, and close breaks pivot wrong way around.
Phát hành các Ghi chú:
v10 | Can now enable/disable the build-in drawings. You can set theme.enable to false if you want to build your own lines / labels.

Updated:
Theme
  Used to create a (color) theme to draw Zigzag
  Fields:
    enabled (series bool)
    colorDefault (series color)
    colorNeutral (series color)
    colorBullish (series color)
    colorBearish (series color)
    labelSize (series string)
    lineWidth (series int)
    coloredLines (series bool)
    showCloseInfo (series bool)
    showTooltips (series bool)
    tooltips (Tooltips)
Thư viện Pine

Với tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác từ cộng đồng của chúng tôi có thể sử dụng lại nó. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này một cách riêng tư hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy chung.

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

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng thư viện này?

Sao chép văn bản vào khay nhớ tạm và dán nó vào tập lệnh của bạn.