PINE LIBRARY

Drawing

Library "Drawing"
User Defined types and methods for basic drawing structure. Consolidated from the earlier libraries - DrawingTypes and DrawingMethods

method get_price(this, bar)
  get line price based on bar
  Namespace types: Line
  Parameters:
    this (Line): (series Line) Line object.
    bar (int): (series/int) bar at which line price need to be calculated
  Returns: line price at given bar.

method init(this)
  Namespace types: PolyLine
  Parameters:
    this (PolyLine)

method tostring(this, sortKeys, sortOrder, includeKeys)
  Converts DrawingTypes/Point object to string representation
  Namespace types: chart.point
  Parameters:
    this (chart.point): DrawingTypes/Point object
    sortKeys (bool): If set to true, string output is sorted by keys.
    sortOrder (int): Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
    includeKeys (array<string>): Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/Point

method tostring(this, sortKeys, sortOrder, includeKeys)
  Converts DrawingTypes/LineProperties object to string representation
  Namespace types: LineProperties
  Parameters:
    this (LineProperties): DrawingTypes/LineProperties object
    sortKeys (bool): If set to true, string output is sorted by keys.
    sortOrder (int): Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
    includeKeys (array<string>): Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/LineProperties

method tostring(this, sortKeys, sortOrder, includeKeys)
  Converts DrawingTypes/Line object to string representation
  Namespace types: Line
  Parameters:
    this (Line): DrawingTypes/Line object
    sortKeys (bool): If set to true, string output is sorted by keys.
    sortOrder (int): Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
    includeKeys (array<string>): Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/Line

method tostring(this, sortKeys, sortOrder, includeKeys)
  Converts DrawingTypes/LabelProperties object to string representation
  Namespace types: LabelProperties
  Parameters:
    this (LabelProperties): DrawingTypes/LabelProperties object
    sortKeys (bool): If set to true, string output is sorted by keys.
    sortOrder (int): Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
    includeKeys (array<string>): Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/LabelProperties

method tostring(this, sortKeys, sortOrder, includeKeys)
  Converts DrawingTypes/Label object to string representation
  Namespace types: Label
  Parameters:
    this (Label): DrawingTypes/Label object
    sortKeys (bool): If set to true, string output is sorted by keys.
    sortOrder (int): Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
    includeKeys (array<string>): Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/Label

method tostring(this, sortKeys, sortOrder, includeKeys)
  Converts DrawingTypes/Linefill object to string representation
  Namespace types: Linefill
  Parameters:
    this (Linefill): DrawingTypes/Linefill object
    sortKeys (bool): If set to true, string output is sorted by keys.
    sortOrder (int): Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
    includeKeys (array<string>): Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/Linefill

method tostring(this, sortKeys, sortOrder, includeKeys)
  Converts DrawingTypes/BoxProperties object to string representation
  Namespace types: BoxProperties
  Parameters:
    this (BoxProperties): DrawingTypes/BoxProperties object
    sortKeys (bool): If set to true, string output is sorted by keys.
    sortOrder (int): Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
    includeKeys (array<string>): Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/BoxProperties

method tostring(this, sortKeys, sortOrder, includeKeys)
  Converts DrawingTypes/BoxText object to string representation
  Namespace types: BoxText
  Parameters:
    this (BoxText): DrawingTypes/BoxText object
    sortKeys (bool): If set to true, string output is sorted by keys.
    sortOrder (int): Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
    includeKeys (array<string>): Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/BoxText

method tostring(this, sortKeys, sortOrder, includeKeys)
  Converts DrawingTypes/Box object to string representation
  Namespace types: Box
  Parameters:
    this (Box): DrawingTypes/Box object
    sortKeys (bool): If set to true, string output is sorted by keys.
    sortOrder (int): Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
    includeKeys (array<string>): Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
  Returns: string representation of DrawingTypes/Box

method delete(this)
  Deletes line from DrawingTypes/Line object
  Namespace types: Line
  Parameters:
    this (Line): DrawingTypes/Line object
  Returns: Line object deleted

method delete(this)
  Deletes label from DrawingTypes/Label object
  Namespace types: Label
  Parameters:
    this (Label): DrawingTypes/Label object
  Returns: Label object deleted

method delete(this)
  Deletes Linefill from DrawingTypes/Linefill object
  Namespace types: Linefill
  Parameters:
    this (Linefill): DrawingTypes/Linefill object
  Returns: Linefill object deleted

method delete(this)
  Deletes box from DrawingTypes/Box object
  Namespace types: Box
  Parameters:
    this (Box): DrawingTypes/Box object
  Returns: DrawingTypes/Box object deleted

method delete(this)
  Deletes lines from array of DrawingTypes/Line objects
  Namespace types: array<Line>
  Parameters:
    this (array<Line>): Array of DrawingTypes/Line objects
  Returns: Array of DrawingTypes/Line objects

method delete(this)
  Deletes labels from array of DrawingTypes/Label objects
  Namespace types: array<Label>
  Parameters:
    this (array<Label>): Array of DrawingTypes/Label objects
  Returns: Array of DrawingTypes/Label objects

method delete(this)
  Deletes linefill from array of DrawingTypes/Linefill objects
  Namespace types: array<Linefill>
  Parameters:
    this (array<Linefill>): Array of DrawingTypes/Linefill objects
  Returns: Array of DrawingTypes/Linefill objects

method delete(this)
  Deletes boxes from array of DrawingTypes/Box objects
  Namespace types: array<Box>
  Parameters:
    this (array<Box>): Array of DrawingTypes/Box objects
  Returns: Array of DrawingTypes/Box objects

method clear(this)
  clear items from array of DrawingTypes/Line while deleting underlying objects
  Namespace types: array<Line>
  Parameters:
    this (array<Line>): array<DrawingTypes/Line>
  Returns: void

method clear(this)
  clear items from array of DrawingTypes/Label while deleting underlying objects
  Namespace types: array<Label>
  Parameters:
    this (array<Label>): array<DrawingTypes/Label>
  Returns: void

method clear(this)
  clear items from array of DrawingTypes/Linefill while deleting underlying objects
  Namespace types: array<Linefill>
  Parameters:
    this (array<Linefill>): array<DrawingTypes/Linefill>
  Returns: void

method clear(this)
  clear items from array of DrawingTypes/Box while deleting underlying objects
  Namespace types: array<Box>
  Parameters:
    this (array<Box>): array<DrawingTypes/Box>
  Returns: void

method draw(this)
  Creates line from DrawingTypes/Line object
  Namespace types: Line
  Parameters:
    this (Line): DrawingTypes/Line object
  Returns: line created from DrawingTypes/Line object

method draw(this)
  Creates lines from array of DrawingTypes/Line objects
  Namespace types: array<Line>
  Parameters:
    this (array<Line>): Array of DrawingTypes/Line objects
  Returns: Array of DrawingTypes/Line objects

method draw(this)
  Creates label from DrawingTypes/Label object
  Namespace types: Label
  Parameters:
    this (Label): DrawingTypes/Label object
  Returns: label created from DrawingTypes/Label object

method draw(this)
  Creates labels from array of DrawingTypes/Label objects
  Namespace types: array<Label>
  Parameters:
    this (array<Label>): Array of DrawingTypes/Label objects
  Returns: Array of DrawingTypes/Label objects

method draw(this)
  Creates linefill object from DrawingTypes/Linefill
  Namespace types: Linefill
  Parameters:
    this (Linefill): DrawingTypes/Linefill objects
  Returns: linefill object created

method draw(this)
  Creates linefill objects from array of DrawingTypes/Linefill objects
  Namespace types: array<Linefill>
  Parameters:
    this (array<Linefill>): Array of DrawingTypes/Linefill objects
  Returns: Array of DrawingTypes/Linefill used for creating linefills

method draw(this)
  Creates box from DrawingTypes/Box object
  Namespace types: Box
  Parameters:
    this (Box): DrawingTypes/Box object
  Returns: box created from DrawingTypes/Box object

method draw(this)
  Creates labels from array of DrawingTypes/Label objects
  Namespace types: array<Box>
  Parameters:
    this (array<Box>): Array of DrawingTypes/Label objects
  Returns: Array of DrawingTypes/Label objects

method createLabel(this, lblText, tooltip, properties)
  Creates DrawingTypes/Label object from DrawingTypes/Point
  Namespace types: chart.point
  Parameters:
    this (chart.point): DrawingTypes/Point object
    lblText (string): Label text
    tooltip (string): Tooltip text. Default is na
    properties (LabelProperties): DrawingTypes/LabelProperties object. Default is na - meaning default values are used.
  Returns: DrawingTypes/Label object

method createLine(this, other, properties)
  Creates DrawingTypes/Line object from one DrawingTypes/Point to other
  Namespace types: chart.point
  Parameters:
    this (chart.point): First DrawingTypes/Point object
    other (chart.point): Second DrawingTypes/Point object
    properties (LineProperties): DrawingTypes/LineProperties object. Default set to na - meaning default values are used.
  Returns: DrawingTypes/Line object

method createLinefill(this, other, fillColor, transparency)
  Creates DrawingTypes/Linefill object from DrawingTypes/Line object to other DrawingTypes/Line object
  Namespace types: Line
  Parameters:
    this (Line): First DrawingTypes/Line object
    other (Line): Other DrawingTypes/Line object
    fillColor (color): fill color of linefill. Default is color.blue
    transparency (int): fill transparency for linefill. Default is 80
  Returns: Array of DrawingTypes/Linefill object

method createBox(this, other, properties, textProperties)
  Creates DrawingTypes/Box object from one DrawingTypes/Point to other
  Namespace types: chart.point
  Parameters:
    this (chart.point): First DrawingTypes/Point object
    other (chart.point): Second DrawingTypes/Point object
    properties (BoxProperties): DrawingTypes/BoxProperties object. Default set to na - meaning default values are used.
    textProperties (BoxText): DrawingTypes/BoxText object. Default is na - meaning no text will be drawn
  Returns: DrawingTypes/Box object

method createBox(this, properties, textProperties)
  Creates DrawingTypes/Box object from DrawingTypes/Line as diagonal line
  Namespace types: Line
  Parameters:
    this (Line): Diagonal DrawingTypes/PoLineint object
    properties (BoxProperties): DrawingTypes/BoxProperties object. Default set to na - meaning default values are used.
    textProperties (BoxText): DrawingTypes/BoxText object. Default is na - meaning no text will be drawn
  Returns: DrawingTypes/Box object

LineProperties
  Properties of line object
  Fields:
    xloc (series string): X Reference - can be either xloc.bar_index or xloc.bar_time. Default is xloc.bar_index
    extend (series string): Property which sets line to extend towards either right or left or both. Valid values are extend.right, extend.left, extend.both, extend.none. Default is extend.none
    color (series color): Line color
    style (series string): Line style, valid values are line.style_solid, line.style_dashed, line.style_dotted, line.style_arrow_left, line.style_arrow_right, line.style_arrow_both. Default is line.style_solid
    width (series int): Line width. Default is 1

Line
  Line object created from points
  Fields:
    start (chart.point): Starting point of the line
    end (chart.point): Ending point of the line
    properties (LineProperties): LineProperties object which defines the style of line
    object (series line): Derived line object

LabelProperties
  Properties of label object
  Fields:
    xloc (series string): X Reference - can be either xloc.bar_index or xloc.bar_time. Default is xloc.bar_index
    yloc (series string): Y reference - can be yloc.price, yloc.abovebar, yloc.belowbar. Default is yloc.price
    color (series color): Label fill color
    style (series string): Label style as defined in Tradingview Documentation. Default is label.style_none
    textcolor (series color): text color. Default is color.black
    size (series string): Label text size. Default is size.normal. Other values are size.auto, size.tiny, size.small, size.normal, size.large, size.huge
    textalign (series string): Label text alignment. Default if text.align_center. Other allowed values - text.align_right, text.align_left, text.align_top, text.align_bottom
    text_font_family (series string): The font family of the text. Default value is font.family_default. Other available option is font.family_monospace

Label
  Label object
  Fields:
    point (chart.point): Point where label is drawn
    lblText (series string): label text
    tooltip (series string): Tooltip text. Default is na
    properties (LabelProperties): LabelProperties object
    object (series label): Pine label object

Linefill
  Linefill object
  Fields:
    line1 (Line): First line to create linefill
    line2 (Line): Second line to create linefill
    fillColor (series color): Fill color
    transparency (series int): Fill transparency range from 0 to 100
    object (series linefill): linefill object created from wrapper

BoxProperties
  BoxProperties object
  Fields:
    border_color (series color): Box border color. Default is color.blue
    bgcolor (series color): box background color
    border_width (series int): Box border width. Default is 1
    border_style (series string): Box border style. Default is line.style_solid
    extend (series string): Extend property of box. default is extend.none
    xloc (series string): defines if drawing needs to be done based on bar index or time. default is xloc.bar_index

BoxText
  Box Text properties.
  Fields:
    boxText (series string): Text to be printed on the box
    text_size (series string): Text size. Default is size.auto
    text_color (series color): Box text color. Default is color.yellow.
    text_halign (series string): horizontal align style - default is text.align_center
    text_valign (series string): vertical align style - default is text.align_center
    text_wrap (series string): text wrap style - default is text.wrap_auto
    text_font_family (series string): Text font. Default is

Box
  Box object
  Fields:
    p1 (chart.point): Diagonal point one
    p2 (chart.point): Diagonal point two
    properties (BoxProperties): Box properties
    textProperties (BoxText): Box text properties
    object (series box): Box object created

PolyLineProperties
  Fields:
    curved (series bool)
    closed (series bool)
    xloc (series string)
    lineColor (series color)
    fillColor (series color)
    lineStyle (series string)
    lineWidth (series int)

PolyLine
  Fields:
    points (array<chart.point>)
    properties (PolyLineProperties)
    object (series polyline)
arraysdisplaydrawinghewhomustnotbenamedMarket Geometrytrendoscope

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