Library "chartpatterns"
Library having complete chart pattern implementation

method draw(this)
  draws pattern on the chart
  Namespace types: Pattern
  Parameters:
    this (Pattern): Pattern object that needs to be drawn
  Returns: Current Pattern object

method erase(this)
  erase the given pattern on the chart
  Namespace types: Pattern
  Parameters:
    this (Pattern): Pattern object that needs to be erased
  Returns: Current Pattern object

method findPattern(this, properties, patterns)
  Find patterns based on the currect zigzag object and store them in the patterns array
  Namespace types: zg.Zigzag
  Parameters:
    this (Zigzag type from Trendoscope/ZigzagLite/2): Zigzag object containing pivots
    properties (PatternProperties): PatternProperties object
    patterns (Pattern[]): Array of Pattern objects
  Returns: Current Pattern object

PatternProperties
  Object containing properties for pattern scanning
  Fields:
    offset (series int): Zigzag pivot offset. Set it to 1 for non repainting scan.
    numberOfPivots (series int): Number of pivots to be used in pattern search. Can be either 5 or 6
    errorRatio (series float): Error Threshold to be considered for comparing the slope of lines
    flatRatio (series float): Retracement ratio threshold used to determine if the lines are flat
    checkBarRatio (series bool): Also check bar ratio are within the limits while scanning the patterns
    barRatioLimit (series float): Bar ratio limit used for checking the bars. Used only when checkBarRatio is set to true
    avoidOverlap (series bool)
    patternLineWidth (series int): Line width of the pattern trend lines
    showZigzag (series bool): show zigzag associated with pattern
    zigzagLineWidth (series int): line width of the zigzag lines. Used only when showZigzag is set to true
    zigzagLineColor (series color): color of the zigzag lines. Used only when showZigzag is set to true
    showPatternLabel (series bool): display pattern label containing the name
    patternLabelSize (series string): size of the pattern label. Used only when showPatternLabel is set to true
    showPivotLabels (series bool): Display pivot labels of the patterns marking 1-6
    pivotLabelSize (series string): size of the pivot label. Used only when showPivotLabels is set to true
    pivotLabelColor (series color): color of the pivot label outline. chart.bg_color or chart.fg_color are the appropriate values.
    allowedPatterns (bool[]): array of bool encoding the allowed pattern types.
    themeColors (color[]): color array of themes to be used.

Pattern
  Object containing Individual Pattern data
  Fields:
    pivots (Pivot[] type from Trendoscope/ZigzagLite/2): array of Zigzag Pivot points
    trendLine1 (Line type from Trendoscope/LineWrapper/1): First trend line joining pivots 1, 3, 5
    trendLine2 (Line type from Trendoscope/LineWrapper/1): Second trend line joining pivots 2, 4 (, 6)
    properties (PatternProperties): PatternProperties Object carrying common properties
    patternColor (series color): Individual pattern color. Lines and labels will be using this color.
    ratioDiff (series float): Difference between trendLine1 and trendLine2 ratios
    zigzagLine (series polyline): Internal zigzag line drawing Object
    pivotLabels (label[]): array containning Pivot labels
    patternLabel (series label): pattern label Object
    patternType (series int): integer representing the pattern type
    patternName (series string): Type of pattern in string
Phát hành các Ghi chú
v2

Updated:
method findPattern(this, properties, patterns, draw)
  Find patterns based on the currect zigzag object and store them in the patterns array
  Namespace types: zg.Zigzag
  Parameters:
    this (Zigzag type from Trendoscope/ZigzagLite/2): Zigzag object containing pivots
    properties (PatternProperties): PatternProperties object
    patterns (Pattern[]): Array of Pattern objects
    draw (bool): pattern is drawn on the chart automatically if set to true
  Returns: Current Pattern object
Phát hành các Ghi chú
v3

Added:
ScanProperties
  Object containing properties for pattern scanning
  Fields:
    offset (series int): Zigzag pivot offset. Set it to 1 for non repainting scan.
    numberOfPivots (series int): Number of pivots to be used in pattern search. Can be either 5 or 6
    errorRatio (series float): Error Threshold to be considered for comparing the slope of lines
    flatRatio (series float): Retracement ratio threshold used to determine if the lines are flat
    checkBarRatio (series bool): Also check bar ratio are within the limits while scanning the patterns
    barRatioLimit (series float): Bar ratio limit used for checking the bars. Used only when checkBarRatio is set to true
    avoidOverlap (series bool)
    allowedPatterns (bool[]): array of bool encoding the allowed pattern types.
    allowedLastPivotDirections (int[]): array of int representing allowed last pivot direction for each pattern types
    themeColors (color[]): color array of themes to be used.

DrawingProperties
  Object containing properties for pattern drawing
  Fields:
    patternLineWidth (series int): Line width of the pattern trend lines
    showZigzag (series bool): show zigzag associated with pattern
    zigzagLineWidth (series int): line width of the zigzag lines. Used only when showZigzag is set to true
    zigzagLineColor (series color): color of the zigzag lines. Used only when showZigzag is set to true
    showPatternLabel (series bool): display pattern label containing the name
    patternLabelSize (series string): size of the pattern label. Used only when showPatternLabel is set to true
    showPivotLabels (series bool): Display pivot labels of the patterns marking 1-6
    pivotLabelSize (series string): size of the pivot label. Used only when showPivotLabels is set to true
    pivotLabelColor (series color): color of the pivot label outline. chart.bg_color or chart.fg_color are the appropriate values.
    deleteOnPop (series bool): delete the pattern when popping out from the array of Patterns.

Updated:
method findPattern(this, properties, dProperties, patterns, ohlcArray, maxLivePatterns, draw)
  Find patterns based on the currect zigzag object and store them in the patterns array
  Namespace types: zg.Zigzag
  Parameters:
    this (Zigzag type from Trendoscope/ZigzagLite/2): Zigzag object containing pivots
    properties (ScanProperties): ScanProperties object
@oaram dProperties DrawingProperties object
    dProperties (DrawingProperties)
    patterns (Pattern[]): Array of Pattern objects
    ohlcArray (OHLC[] type from Trendoscope/ohlc/1)
    maxLivePatterns (int): max number of patterns to be retained in the patterns array
    draw (bool): pattern is drawn on the chart automatically if set to true
  Returns: Current Pattern object

Pattern
  Object containing Individual Pattern data
  Fields:
    pivots (Pivot[] type from Trendoscope/ZigzagLite/2): array of Zigzag Pivot points
    trendLine1 (Line type from Trendoscope/LineWrapper/1): First trend line joining pivots 1, 3, 5
    trendLine2 (Line type from Trendoscope/LineWrapper/1): Second trend line joining pivots 2, 4 (, 6)
    properties (DrawingProperties): DrawingProperties Object carrying common properties
    patternColor (series color): Individual pattern color. Lines and labels will be using this color.
    ratioDiff (series float): Difference between trendLine1 and trendLine2 ratios
    zigzagLine (series polyline): Internal zigzag line drawing Object
    pivotLabels (label[]): array containning Pivot labels
    patternLabel (series label): pattern label Object
    patternType (series int): integer representing the pattern type
    patternName (series string): Type of pattern in string

Removed:
PatternProperties
  Object containing properties for pattern scanning
Phát hành các Ghi chú
v4
Phát hành các Ghi chú
v5

Updated:
ScanProperties
  Object containing properties for pattern scanning
  Fields:
    offset (series int): Zigzag pivot offset. Set it to 1 for non repainting scan.
    numberOfPivots (series int): Number of pivots to be used in pattern search. Can be either 5 or 6
    errorRatio (series float): Error Threshold to be considered for comparing the slope of lines
    flatRatio (series float): Retracement ratio threshold used to determine if the lines are flat
    checkBarRatio (series bool): Also check bar ratio are within the limits while scanning the patterns
    barRatioLimit (series float): Bar ratio limit used for checking the bars. Used only when checkBarRatio is set to true
    avoidOverlap (series bool): avoid overlapping patterns.
    repaint (series bool): allow repainting pattern if the new coordinates are more appropriate
    allowedPatterns (bool[]): array of bool encoding the allowed pattern types.
    allowedLastPivotDirections (int[]): array of int representing allowed last pivot direction for each pattern types
    themeColors (color[]): color array of themes to be used.
Phát hành các Ghi chú
v6

Added:
method createFNP(p, base)
  creates FNP Pattern from base Pattern
  Namespace types: Pattern
  Parameters:
    p (Pattern): Pattern object from which the FNP Pattern needs to be created
    base (chart.point): base point of the flag or pennant
  Returns: Current Pattern object

method push(this, p, maxItems)
  push FNPPattern object to the array by keeping maxItems limit
  Namespace types: FNPPattern[]
  Parameters:
    this (FNPPattern[]): array of FNPPattern objects
    p (FNPPattern): FNPPattern object to be added to array
@oaram maxItems Max number of items the array can hold
    maxItems (int)
  Returns: Current FNPPattern array

method findPatternPlain(this, properties, dProperties, patterns, ohlcArray)
  Find patterns based on the currect zigzag object but will not store them in the pattern array.
  Namespace types: zg.Zigzag
  Parameters:
    this (Zigzag type from Trendoscope/ZigzagLite/2): Zigzag object containing pivots
    properties (ScanProperties): ScanProperties object
@oaram dProperties DrawingProperties object
    dProperties (DrawingProperties)
    patterns (Pattern[]): Array of Pattern objects
    ohlcArray (OHLC[] type from Trendoscope/ohlc/1)
  Returns: Flag indicating if the pattern is valid, Current Pattern object

method findFNP(this, currentPattern, sProperties)
  Find flag and pennant patterns based on the current zigzag object and returns the pattern object along with flag
  Namespace types: zg.Zigzag
  Parameters:
    this (Zigzag type from Trendoscope/ZigzagLite/2): Zigzag object containing pivots
    currentPattern (Pattern): Pattern object to be used as base
    sProperties (ScanProperties): ScanProperties object
  Returns: Flag indicating if the fng pattern is valid, new FNPPattern object

FNPPattern
  Object containing Individual Pattern data
  Fields:
    pivots (Pivot[] type from Trendoscope/ZigzagLite/2): array of Zigzag Pivot points
    trendLine1 (Line type from Trendoscope/LineWrapper/1): First trend line joining pivots 1, 3, 5
    trendLine2 (Line type from Trendoscope/LineWrapper/1): Second trend line joining pivots 2, 4 (, 6)
    baseLine (Line type from Trendoscope/LineWrapper/1): Base line of the flag or pennant
    properties (DrawingProperties): DrawingProperties Object carrying common properties
    patternColor (series color): Individual pattern color. Lines and labels will be using this color.
    ratioDiff (series float): Difference between trendLine1 and trendLine2 ratios
    zigzagLine (series polyline): Internal zigzag line drawing Object
    pivotLabels (label[]): array containning Pivot labels
    patternLabel (series label): pattern label Object
    patternType (series int): integer representing the pattern type
    patternName (series string): Type of pattern in string

Updated:
method draw(this)
  draws pattern on the chart
  Namespace types: FNPPattern
  Parameters:
    this (FNPPattern): FNPPattern object that needs to be drawn
  Returns: Current FNPPattern object

method erase(this)
  erase the given pattern on the chart
  Namespace types: FNPPattern
  Parameters:
    this (FNPPattern): Pattern object that needs to be erased
  Returns: Current Pattern object

ScanProperties
  Object containing properties for pattern scanning
  Fields:
    offset (series int): Zigzag pivot offset. Set it to 1 for non repainting scan.
    numberOfPivots (series int): Number of pivots to be used in pattern search. Can be either 5 or 6
    errorRatio (series float): Error Threshold to be considered for comparing the slope of lines
    flatRatio (series float): Retracement ratio threshold used to determine if the lines are flat
    flagRatio (series float): max ratio threshold for flag and pennnant
    checkBarRatio (series bool): Also check bar ratio are within the limits while scanning the patterns
    barRatioLimit (series float): Bar ratio limit used for checking the bars. Used only when checkBarRatio is set to true
    avoidOverlap (series bool): avoid overlapping patterns.
    repaint (series bool): allow repainting pattern if the new coordinates are more appropriate
    allowedPatterns (bool[]): array of bool encoding the allowed pattern types.
    allowedLastPivotDirections (int[]): array of int representing allowed last pivot direction for each pattern types
    themeColors (color[]): color array of themes to be used.
Phát hành các Ghi chú
v7
Phát hành các Ghi chú
v8
Phát hành các Ghi chú
v9
Phát hành các Ghi chú
v10

Updated:
method findPattern(this, properties, dProperties, patterns, ohlcArray, maxLivePatterns, draw)
  Find patterns based on the currect zigzag object and store them in the patterns array
  Namespace types: zg.Zigzag
  Parameters:
    this (Zigzag type from Trendoscope/ZigzagLite/3): Zigzag object containing pivots
    properties (ScanProperties): ScanProperties object
@oaram dProperties DrawingProperties object
    dProperties (DrawingProperties)
    patterns (array<Pattern>): Array of Pattern objects
    ohlcArray (array<OHLC> type from Trendoscope/ohlc/3)
    maxLivePatterns (int): max number of patterns to be retained in the patterns array
    draw (bool): pattern is drawn on the chart automatically if set to true
  Returns: Current Pattern object

method findPatternPlain(this, properties, dProperties, patterns, ohlcArray)
  Find patterns based on the currect zigzag object but will not store them in the pattern array.
  Namespace types: zg.Zigzag
  Parameters:
    this (Zigzag type from Trendoscope/ZigzagLite/3): Zigzag object containing pivots
    properties (ScanProperties): ScanProperties object
@oaram dProperties DrawingProperties object
    dProperties (DrawingProperties)
    patterns (array<Pattern>): Array of Pattern objects
    ohlcArray (array<OHLC> type from Trendoscope/ohlc/3)
  Returns: Flag indicating if the pattern is valid, Current Pattern object

method findFNP(this, currentPattern, sProperties)
  Find flag and pennant patterns based on the current zigzag object and returns the pattern object along with flag
  Namespace types: zg.Zigzag
  Parameters:
    this (Zigzag type from Trendoscope/ZigzagLite/3): Zigzag object containing pivots
    currentPattern (Pattern): Pattern object to be used as base
    sProperties (ScanProperties): ScanProperties object
  Returns: Flag indicating if the fng pattern is valid, new FNPPattern object

Pattern
  Object containing Individual Pattern data
  Fields:
    pivots (array<Pivot> type from Trendoscope/ZigzagLite/3): array of Zigzag Pivot points
    trendLine1 (Line type from Trendoscope/LineWrapper/2): First trend line joining pivots 1, 3, 5
    trendLine2 (Line type from Trendoscope/LineWrapper/2): Second trend line joining pivots 2, 4 (, 6)
    properties (DrawingProperties): DrawingProperties Object carrying common properties
    patternColor (series color): Individual pattern color. Lines and labels will be using this color.
    ratioDiff (series float): Difference between trendLine1 and trendLine2 ratios
    zigzagLine (series polyline): Internal zigzag line drawing Object
    pivotLabels (array<label>): array containning Pivot labels
    patternLabel (series label): pattern label Object
    patternType (series int): integer representing the pattern type
    patternName (series string): Type of pattern in string

FNPPattern
  Object containing Individual Pattern data
  Fields:
    pivots (array<Pivot> type from Trendoscope/ZigzagLite/3): array of Zigzag Pivot points
    trendLine1 (Line type from Trendoscope/LineWrapper/2): First trend line joining pivots 1, 3, 5
    trendLine2 (Line type from Trendoscope/LineWrapper/2): Second trend line joining pivots 2, 4 (, 6)
    baseLine (Line type from Trendoscope/LineWrapper/2): Base line of the flag or pennant
    properties (DrawingProperties): DrawingProperties Object carrying common properties
    patternColor (series color): Individual pattern color. Lines and labels will be using this color.
    ratioDiff (series float): Difference between trendLine1 and trendLine2 ratios
    zigzagLine (series polyline): Internal zigzag line drawing Object
    pivotLabels (array<label>): array containning Pivot labels
    patternLabel (series label): pattern label Object
    patternType (series int): integer representing the pattern type
    patternName (series string): Type of pattern in string
arrayshewhomustnotbenamedMarket Geometrytechindicatortrendoscopetrianglepattrenwedgepatterns

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