Trendoscope

ReversalChartPatternLibrary

Trendoscope Wizard Updated   
Library "ReversalChartPatternLibrary"
User Defined Types and Methods for reversal chart patterns - Double Top, Double Bottom, Triple Top, Triple Bottom, Cup and Handle, Inverted Cup and Handle, Head and Shoulders, Inverse Head and Shoulders

method delete(this)
  Deletes the drawing components of ReversalChartPatternDrawing object
  Namespace types: ReversalChartPatternDrawing
  Parameters:
    this (ReversalChartPatternDrawing): ReversalChartPatternDrawing object
  Returns: current ReversalChartPatternDrawing object

method delete(this)
  Deletes the drawing components of ReversalChartPattern object. In turn calls the delete of ReversalChartPatternDrawing
  Namespace types: ReversalChartPattern
  Parameters:
    this (ReversalChartPattern): ReversalChartPattern object
  Returns: current ReversalChartPattern object

method lpush(this, obj, limit, deleteOld)
  Array push with limited number of items in the array. Old items are deleted when new one comes and exceeds the limit
  Namespace types: ReversalChartPattern
  Parameters:
    this (ReversalChartPattern): array<ReversalChartPattern> object
    obj (ReversalChartPattern): ReversalChartPattern object which need to be pushed to the array
    limit (int): max items on the array. Default is 10
    deleteOld (bool): If set to true, also deletes the drawing objects. If not, the drawing objects are kept but the pattern object is removed from array. Default is false.
  Returns: current ReversalChartPattern object

method draw(this)
  Draws the components of ReversalChartPatternDrawing
  Namespace types: ReversalChartPatternDrawing
  Parameters:
    this (ReversalChartPatternDrawing): ReversalChartPatternDrawing object
  Returns: current ReversalChartPatternDrawing object

method draw(this)
  Draws the components of ReversalChartPatternDrawing within the ReversalChartPattern object.
  Namespace types: ReversalChartPattern
  Parameters:
    this (ReversalChartPattern): ReversalChartPattern object
  Returns: current ReversalChartPattern object

method scan(zigzag, patterns, errorPercent, shoulderStart, shoulderEnd)
  Scans zigzag for ReversalChartPattern occurences
  Namespace types: zg.Zigzag
  Parameters:
    zigzag (Zigzag type from HeWhoMustNotBeNamed/ZigzagTypes/2): ZigzagTypes.Zigzag object having array of zigzag pivots and other information on each pivots
    patterns (ReversalChartPattern): Existing patterns array. Used for validating duplicates
    errorPercent (float): Error threshold for considering ratios. Default is 13
    shoulderStart (float): Starting range of shoulder ratio. Used for identifying shoulders, handles and necklines
    shoulderEnd (float): Ending range of shoulder ratio. Used for identifying shoulders, handles and necklines
  Returns: int pattern type

method createPattern(zigzag, patternType, patternColor, riskAdjustment)
  Create Pattern from ZigzagTypes.Zigzag object
  Namespace types: zg.Zigzag
  Parameters:
    zigzag (Zigzag type from HeWhoMustNotBeNamed/ZigzagTypes/2): ZigzagTypes.Zigzag object having array of zigzag pivots and other information on each pivots
    patternType (int): Type of pattern being created. 1 - Double Tap, 2 - Triple Tap, 3 - Cup and Handle, 4 - Head and Shoulders
    patternColor (color): Color in which the patterns are drawn
    riskAdjustment (float): Used for calculating stops
  Returns: ReversalChartPattern object created

method getName(this)
  get pattern name of ReversalChartPattern object
  Namespace types: ReversalChartPattern
  Parameters:
    this (ReversalChartPattern): ReversalChartPattern object
  Returns: string name of the pattern

method getDescription(this)
  get consolidated description of ReversalChartPattern object
  Namespace types: ReversalChartPattern
  Parameters:
    this (ReversalChartPattern): ReversalChartPattern object
  Returns: string consolidated description

method init(this)
  initializes the ReversalChartPattern object and creates sub object types
  Namespace types: ReversalChartPattern
  Parameters:
    this (ReversalChartPattern): ReversalChartPattern object
  Returns: ReversalChartPattern current object

ReversalChartPatternDrawing
  Type which holds the drawing objects for Reversal Chart Pattern Types
  Fields:
    patternLines (Line type from HeWhoMustNotBeNamed/DrawingTypes/1): array of Line objects representing pattern
    entry (Line type from HeWhoMustNotBeNamed/DrawingTypes/1): Entry price Line
    target (Line type from HeWhoMustNotBeNamed/DrawingTypes/1): Target price Line
    patternLabel (Label type from HeWhoMustNotBeNamed/DrawingTypes/1)

ReversalChartPattern
  Reversal Chart Pattern master type which holds the pattern components, drawings and trade details
  Fields:
    pivots (Pivot type from HeWhoMustNotBeNamed/ZigzagTypes/2): Array of Zigzag Pivots forming the pattern
    patternType (series int): Defines the main type of pattern 1 - Double Tap, 1 - Triple Tap, 3 - Cup and Handle, 4 - Head and Shoulders
    patternColor (series color): Color in which the pattern will be drawn on chart
    riskAdjustment (series float): Percentage adjustment of risk. Used for setting stops
    drawing (ReversalChartPatternDrawing): ReversalChartPatternDrawing object which holds the drawing components
    trade (Trade type from HeWhoMustNotBeNamed/TradeTracker/1): TradeTracker.Trade object holding trade components
Release Notes:
v2

Updated:
method scan(zigzag, patterns, errorPercent, shoulderStart, shoulderEnd)
  Scans zigzag for ReversalChartPattern occurences
  Namespace types: zg.Zigzag
  Parameters:
    zigzag (Zigzag type from HeWhoMustNotBeNamed/ZigzagTypes/4): ZigzagTypes.Zigzag object having array of zigzag pivots and other information on each pivots
    patterns (ReversalChartPattern): Existing patterns array. Used for validating duplicates
    errorPercent (float): Error threshold for considering ratios. Default is 13
    shoulderStart (float): Starting range of shoulder ratio. Used for identifying shoulders, handles and necklines
    shoulderEnd (float): Ending range of shoulder ratio. Used for identifying shoulders, handles and necklines
  Returns: int pattern type

method createPattern(zigzag, patternType, patternColor, riskAdjustment)
  Create Pattern from ZigzagTypes.Zigzag object
  Namespace types: zg.Zigzag
  Parameters:
    zigzag (Zigzag type from HeWhoMustNotBeNamed/ZigzagTypes/4): ZigzagTypes.Zigzag object having array of zigzag pivots and other information on each pivots
    patternType (int): Type of pattern being created. 1 - Double Tap, 2 - Triple Tap, 3 - Cup and Handle, 4 - Head and Shoulders
    patternColor (color): Color in which the patterns are drawn
    riskAdjustment (float): Used for calculating stops
  Returns: ReversalChartPattern object created

ReversalChartPattern
  Reversal Chart Pattern master type which holds the pattern components, drawings and trade details
  Fields:
    pivots (Pivot type from HeWhoMustNotBeNamed/ZigzagTypes/4): Array of Zigzag Pivots forming the pattern
    patternType (series int): Defines the main type of pattern 1 - Double Tap, 1 - Triple Tap, 3 - Cup and Handle, 4 - Head and Shoulders
    patternColor (series color): Color in which the pattern will be drawn on chart
    riskAdjustment (series float): Percentage adjustment of risk. Used for setting stops
    drawing (ReversalChartPatternDrawing): ReversalChartPatternDrawing object which holds the drawing components
    trade (Trade type from HeWhoMustNotBeNamed/TradeTracker/1): TradeTracker.Trade object holding trade components
Release Notes:
v3

Added:
ReversalChartTradeProperties
  Trade properties of ReversalChartPattern
  Fields:
    riskAdjustment (series float): Risk Adjustment for calculation of stop
    useFixedTarget (series bool): Boolean flag saying use fixed target type wherever possible. If fixed target type is not possible, then risk reward/fib ratios are used for calculation of targets
    variableTargetType (series int): Integer value which defines whether to use fib based targets or risk reward based targets. 1 - Risk Reward, 2 - Fib Ratios
    variableTargetRatios (float): Risk reward or Fib Ratios to be used for calculation of targets when fixed target is not possible or not enabled
    entryPivotForWm (series int): which Pivot should be considered as entry point for WM patterns. 0 refers to the latest breakout pivot where as 5 refers to initial pivot of the pattern

Updated:
method scan(zigzag, patterns, errorPercent, shoulderStart, shoulderEnd, allowedPatterns, offset)
  Scans zigzag for ReversalChartPattern occurences
  Namespace types: zg.Zigzag
  Parameters:
    zigzag (Zigzag type from HeWhoMustNotBeNamed/ZigzagTypes/5): ZigzagTypes.Zigzag object having array of zigzag pivots and other information on each pivots
    patterns (ReversalChartPattern): Existing patterns array. Used for validating duplicates
    errorPercent (float): Error threshold for considering ratios. Default is 13
    shoulderStart (float): Starting range of shoulder ratio. Used for identifying shoulders, handles and necklines
    shoulderEnd (float): Ending range of shoulder ratio. Used for identifying shoulders, handles and necklines
    allowedPatterns (int): array of int containing allowed pattern types
    offset (int): Offset of zigzag to consider only confirmed pivots
  Returns: int pattern type

method createPattern(zigzag, patternType, patternColor, properties, offset)
  Create Pattern from ZigzagTypes.Zigzag object
  Namespace types: zg.Zigzag
  Parameters:
    zigzag (Zigzag type from HeWhoMustNotBeNamed/ZigzagTypes/5): ZigzagTypes.Zigzag object having array of zigzag pivots and other information on each pivots
    patternType (int): Type of pattern being created. 1 - Double Tap, 2 - Triple Tap, 3 - Cup and Handle, 4 - Head and Shoulders
    patternColor (color): Color in which the patterns are drawn
    properties (ReversalChartTradeProperties)
    offset (int)
  Returns: ReversalChartPattern object created

ReversalChartPatternDrawing
  Type which holds the drawing objects for Reversal Chart Pattern Types
  Fields:
    patternLines (Line type from HeWhoMustNotBeNamed/DrawingTypes/2): array of Line objects representing pattern
    entry (Line type from HeWhoMustNotBeNamed/DrawingTypes/2): Entry price Line
    targets (Line type from HeWhoMustNotBeNamed/DrawingTypes/2)
    stop (Line type from HeWhoMustNotBeNamed/DrawingTypes/2): Stop price Line
    patternLabel (Label type from HeWhoMustNotBeNamed/DrawingTypes/2)

ReversalChartPattern
  Reversal Chart Pattern master type which holds the pattern components, drawings and trade details
  Fields:
    pivots (Pivot type from HeWhoMustNotBeNamed/ZigzagTypes/5): Array of Zigzag Pivots forming the pattern
    patternType (series int): Defines the main type of pattern 1 - Double Tap, 1 - Triple Tap, 3 - Cup and Handle, 4 - Head and Shoulders, 5- W/M Patterns, 6 - Full Trend, 7 - Half Trend
    patternColor (series color): Color in which the pattern will be drawn on chart
    properties (ReversalChartTradeProperties)
    drawing (ReversalChartPatternDrawing): ReversalChartPatternDrawing object which holds the drawing components
    trade (Trade type from HeWhoMustNotBeNamed/TradeTracker/1): TradeTracker.Trade object holding trade components
Release Notes:
v4

Few logical updates

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 a publication 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.

Want to use this library?

Copy the following line and paste it in your script.