PINE LIBRARY
chartpatterns

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 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: Pattern
โโParameters:
โโโโthis (Pattern): Pattern object that needs to be erased
โโReturns: Current Pattern 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
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 Pattern object to the array by keeping maxItems limit
โโNamespace types: array<Pattern>
โโParameters:
โโโโthis (array<Pattern>): array of Pattern objects
โโโโp (Pattern): Pattern object to be added to array
@oaram maxItems Max number of items the array can hold
โโโโmaxItems (int)
โโReturns: Current Pattern array
method push(this, p, maxItems)
โโpush FNPPattern object to the array by keeping maxItems limit
โโNamespace types: array<FNPPattern>
โโParameters:
โโโโthis (array<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 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
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 (array<bool>): array of bool encoding the allowed pattern types.
โโโโallowedLastPivotDirections (array<int>): array of int representing allowed last pivot direction for each pattern types
โโโโthemeColors (array<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.
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
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 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: Pattern
โโParameters:
โโโโthis (Pattern): Pattern object that needs to be erased
โโReturns: Current Pattern 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
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 Pattern object to the array by keeping maxItems limit
โโNamespace types: array<Pattern>
โโParameters:
โโโโthis (array<Pattern>): array of Pattern objects
โโโโp (Pattern): Pattern object to be added to array
@oaram maxItems Max number of items the array can hold
โโโโmaxItems (int)
โโReturns: Current Pattern array
method push(this, p, maxItems)
โโpush FNPPattern object to the array by keeping maxItems limit
โโNamespace types: array<FNPPattern>
โโParameters:
โโโโthis (array<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 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
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 (array<bool>): array of bool encoding the allowed pattern types.
โโโโallowedLastPivotDirections (array<int>): array of int representing allowed last pivot direction for each pattern types
โโโโthemeColors (array<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.
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
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.