PINE LIBRARY

chartpatterns

204
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

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.