PINE LIBRARY

lib_plot_objects

已更新
Library "lib_plot_objects"
library wrapping basic builtin object constructors, to be able to do calculations with points/lines/boxes/triangles/polygons via libraries and on securities. inspired by Trendoscope's (
DrawingTypes
and tradingview.com/script/eNM7BFaR-DrawingMethods/) with added update mechanism to not have to recreate objects on every iteration for continously drawn items, automated xloc selection for coordinates, compatibility check for Points, added Triangle and Polygon types, object reflection via tostring to valid json (logging via webhook)

method assert_same_xloc(a, b, test)
  checks two points for compatibility, i.e. having the same xloc
  Namespace types: Point
  Parameters:
    a (Point)
    b (Point)
    test (Test type from robbatt/lib_unit/6)

method assert_same_xloc(a, b, test)
  checks two lines for compatibility, i.e. having the same xloc
  Namespace types: Line
  Parameters:
    a (Line)
    b (Line)
    test (Test type from robbatt/lib_unit/6)

method or_default(args)
  checks args oject for being na, if so, provide a default instead
  Namespace types: LineArgs
  Parameters:
    args (LineArgs)

method or_default(args)
  checks args oject for being na, if so, provide a default instead
  Namespace types: LabelArgs
  Parameters:
    args (LabelArgs)

method or_default(args)
  checks args oject for being na, if so, provide a default instead
  Namespace types: BoxArgs
  Parameters:
    args (BoxArgs)

method or_default(args)
  checks args oject for being na, if so, provide a default instead
  Namespace types: BoxTextArgs
  Parameters:
    args (BoxTextArgs)

method x(point, xloc)
  automatically returns the correct x coordinate, based on the point's set xloc
  Namespace types: Point
  Parameters:
    point (Point)
    xloc (string)

method tostring(this, date_format)
  converts object to json representation
  Namespace types: Point
  Parameters:
    this (Point)
    date_format (string)

method tostring(this, date_format)
  converts object to json representation
  Namespace types: Point[]
  Parameters:
    this (Point[])
    date_format (string)

method tostring(this)
  converts object to json representation
  Namespace types: LineArgs
  Parameters:
    this (LineArgs)

method tostring(this, date_format)
  converts object to json representation
  Namespace types: Line
  Parameters:
    this (Line)
    date_format (string)

method tostring(this)
  Namespace types: LabelArgs
  Parameters:
    this (LabelArgs)

method tostring(this, date_format)
  Namespace types: Label
  Parameters:
    this (Label)
    date_format (string)

method tostring(this, date_format)
  Namespace types: LineFill
  Parameters:
    this (LineFill)
    date_format (string)

method tostring(this)
  Namespace types: BoxArgs
  Parameters:
    this (BoxArgs)

method tostring(this)
  Namespace types: BoxTextArgs
  Parameters:
    this (BoxTextArgs)

method tostring(this, date_format)
  Namespace types: Box
  Parameters:
    this (Box)
    date_format (string)

method tostring(this, date_format)
  Namespace types: Triangle
  Parameters:
    this (Triangle)
    date_format (string)

method tostring(this, date_format)
  Namespace types: TriangleFill
  Parameters:
    this (TriangleFill)
    date_format (string)

method tostring(this, date_format)
  Namespace types: Polygon
  Parameters:
    this (Polygon)
    date_format (string)

method tostring(this, date_format)
  Namespace types: PolygonFill
  Parameters:
    this (PolygonFill)
    date_format (string)

method tostring(this, date_format)
  Namespace types: Line[]
  Parameters:
    this (Line[])
    date_format (string)

method tostring(this, date_format)
  Namespace types: Box[]
  Parameters:
    this (Box[])
    date_format (string)

method tostring(this, date_format)
  Namespace types: Triangle[]
  Parameters:
    this (Triangle[])
    date_format (string)

method tostring(this, date_format)
  Namespace types: Polygon[]
  Parameters:
    this (Polygon[])
    date_format (string)

method tostring(this, date_format)
  Namespace types: PolygonFill[]
  Parameters:
    this (PolygonFill[])
    date_format (string)

method create_center(points)
  Namespace types: Point[]
  Parameters:
    points (Point[])

method create_center(this, other)
  Namespace types: Point
  Parameters:
    this (Point)
    other (Point)

method create_center(this)
  Namespace types: Line
  Parameters:
    this (Line)

method create_line(this, other, args)
  Namespace types: Point
  Parameters:
    this (Point)
    other (Point)
    args (LineArgs)

method create_triangle(this, b, c, args)
  Namespace types: Point
  Parameters:
    this (Point)
    b (Point)
    c (Point)
    args (LineArgs)

method create_triangle(this, c)
  Namespace types: Line
  Parameters:
    this (Line)
    c (Point)

method create_box(this, other, txt, args, text_args)
  Namespace types: Point
  Parameters:
    this (Point)
    other (Point)
    txt (string)
    args (BoxArgs)
    text_args (BoxTextArgs)

method create_box(this, txt, args, text_args)
  Namespace types: Line
  Parameters:
    this (Line)
    txt (string)
    args (BoxArgs)
    text_args (BoxTextArgs)

method create_polygon(points, args)
  Namespace types: Point[]
  Parameters:
    points (Point[])
    args (LineArgs)

method create_polygon(start, others, args)
  Namespace types: Point
  Parameters:
    start (Point)
    others (Point[])
    args (LineArgs)

method create_fill(this, other, fill_color)
  Namespace types: Line
  Parameters:
    this (Line)
    other (Line)
    fill_color (color)

method create_fill(this, fill_color)
  Namespace types: Triangle
  Parameters:
    this (Triangle)
    fill_color (color)

method create_fill(this, fill_color)
  Namespace types: Polygon
  Parameters:
    this (Polygon)
    fill_color (color)

method create_label(this, txt, args, tooltip)
  Namespace types: Point
  Parameters:
    this (Point)
    txt (string)
    args (LabelArgs)
    tooltip (string)

method create_label(this, txt, args, tooltip)
  Namespace types: Line
  Parameters:
    this (Line)
    txt (string)
    args (LabelArgs)
    tooltip (string)

method create_label(this, txt, args, tooltip)
  Namespace types: Box
  Parameters:
    this (Box)
    txt (string)
    args (LabelArgs)
    tooltip (string)

method create_label(this, txt, args, tooltip)
  Namespace types: Triangle
  Parameters:
    this (Triangle)
    txt (string)
    args (LabelArgs)
    tooltip (string)

method create_label(this, txt, args, tooltip)
  Namespace types: Polygon
  Parameters:
    this (Polygon)
    txt (string)
    args (LabelArgs)
    tooltip (string)

method update(this, bar_time, bar_idx, price)
  Namespace types: Point
  Parameters:
    this (Point)
    bar_time (int)
    bar_idx (int)
    price (float)

method update(this, update)
  Namespace types: Point
  Parameters:
    this (Point)
    update (Point)

method update(this, point)
  Namespace types: Label
  Parameters:
    this (Label)
    point (Point)

method update(this, start, end)
  Namespace types: Line
  Parameters:
    this (Line)
    start (Point)
    end (Point)

method update(this, left_top, right_bottom)
  Namespace types: Box
  Parameters:
    this (Box)
    left_top (Point)
    right_bottom (Point)

method update(this, a, b, c)
  Namespace types: Triangle
  Parameters:
    this (Triangle)
    a (Point)
    b (Point)
    c (Point)

method update(this, points)
  Namespace types: Polygon
  Parameters:
    this (Polygon)
    points (Point[])

method delete(this)
  Namespace types: Line
  Parameters:
    this (Line)

method delete(this)
  Namespace types: Label
  Parameters:
    this (Label)

method delete(this)
  Namespace types: LineFill
  Parameters:
    this (LineFill)

method delete(this)
  Namespace types: Box
  Parameters:
    this (Box)

method delete(this)
  Namespace types: TriangleFill
  Parameters:
    this (TriangleFill)

method delete(this)
  Namespace types: Triangle
  Parameters:
    this (Triangle)

method delete(this)
  Namespace types: Polygon
  Parameters:
    this (Polygon)

method delete(this)
  Namespace types: PolygonFill
  Parameters:
    this (PolygonFill)

method delete(this)
  Namespace types: Line[]
  Parameters:
    this (Line[])

method delete(this)
  Namespace types: Label[]
  Parameters:
    this (Label[])

method delete(this)
  Namespace types: LineFill[]
  Parameters:
    this (LineFill[])

method delete(this)
  Namespace types: Box[]
  Parameters:
    this (Box[])

method delete(this)
  Namespace types: TriangleFill[]
  Parameters:
    this (TriangleFill[])

method delete(this)
  Namespace types: Polygon[]
  Parameters:
    this (Polygon[])

method delete(this)
  Namespace types: Triangle[]
  Parameters:
    this (Triangle[])

method delete(this)
  Namespace types: PolygonFill[]
  Parameters:
    this (PolygonFill[])

method draw(this)
  Namespace types: Label
  Parameters:
    this (Label)

method draw(this)
  Namespace types: Line
  Parameters:
    this (Line)

method draw(this)
  Namespace types: Box
  Parameters:
    this (Box)

method draw(this)
  Namespace types: Triangle
  Parameters:
    this (Triangle)

method draw(this)
  Namespace types: Polygon
  Parameters:
    this (Polygon)

method draw(this)
  Namespace types: LineFill
  Parameters:
    this (LineFill)

method draw(this)
  Namespace types: TriangleFill
  Parameters:
    this (TriangleFill)

method draw(this)
  Namespace types: PolygonFill
  Parameters:
    this (PolygonFill)

Point
  Fields:
    bar_time (series int): time based x coordinate
    bar_idx (series int): bar index based x coordinate
    price (series float): price based y coordinate
    xloc (series string): To select if x coordinate is represented by bar_idx or bar_time. Possible values: xloc.bar_index and xloc.bar_time. Default is xloc.bar_index.

LabelArgs
  Fields:
    text_color (series color): Text color.
    bg_color (series color): Color of the label border and arrow.
    text_font_family (series string): The font family of the text. Optional. The default value is font.family_default. Possible values: font.family_default, font.family_monospace.
    yloc (series string): Possible values are yloc.price, yloc.abovebar, yloc.belowbar. If yloc=yloc.price, y argument specifies the price of the label position. If yloc=yloc.abovebar, label is located above bar. If yloc=yloc.belowbar, label is located below bar. Default is yloc.price.
    style (series string): Label style. Possible values: label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond, label.style_text_outline. Default is label.style_label_down.
    size (series string): Label size. Possible values: size.auto, size.tiny, size.small, size.normal, size.large, size.huge. Default value is size.normal.
    text_align (series string): Label text alignment. Possible values: text.align_left, text.align_center, text.align_right. Default value is text.align_center.

Label
  Fields:
    point (Point): The Label coordinates
    txt (series string): Label text. Default is empty string.
    args (LabelArgs): Wrapper for reusable arguments for label.new()
    tooltip (series string): Hover to see tooltip label.
    plot (series label): The label object to be added and plotted via draw()

LineArgs
  Fields:
    line_color (series color): Line color.
    style (series string): Line style. Possible values: line.style_solid, line.style_dotted, line.style_dashed, line.style_arrow_left, line.style_arrow_right, line.style_arrow_both.
    width (series int): Line width in pixels.
    extend (series string): f extend=extend.none, draws segment starting at point (x1, y1) and ending at point (x2, y2). If extend is equal to extend.right or extend.left, draws a ray starting at point (x1, y1) or (x2, y2), respectively. If extend=extend.both, draws a straight line that goes through these points. Default value is extend.none.

Line
  Fields:
    start (Point): starting point of the line
    end (Point)
    args (LineArgs): Wrapper for reusable arguments for line.new()
    plot (series line): The line object to be added and plotted via draw()

LineFill
  Fields:
    a (Line): The first Line object
    b (Line): The second Line object
    fill_color (series color): The color used to fill the space between the lines.
    plot (series linefill): The linefill object to be added and plotted via draw()

BoxArgs
  Fields:
    border_color (series color): Color of the four borders. Optional. The default is color.blue.
    border_width (series int): Width of the four borders, in pixels. Optional. The default is 1 pixel.
    border_style (series string): Style of the four borders. Possible values: line.style_solid, line.style_dotted, line.style_dashed. Optional. The default value is line.style_solid.
    bg_color (series color): Background color of the box. Optional. The default is color.blue.
    extend (series string): When extend.none is used, the horizontal borders start at the left border and end at the right border. With extend.left or extend.right, the horizontal borders are extended indefinitely to the left or right of the box, respectively. With extend.both, the horizontal borders are extended on both sides. Optional. The default value is extend.none.

BoxTextArgs
  Fields:
    text_color (series color): The color of the text. Optional. The default is color.black.
    text_size (series string): The size of the text. An optional parameter, the default value is size.auto. Possible values: size.auto, size.tiny, size.small, size.normal, size.large, size.huge.
    text_halign (series string): The horizontal alignment of the box's text. Optional. The default value is text.align_center. Possible values: text.align_left, text.align_center, text.align_right.
    text_valign (series string): The vertical alignment of the box's text. Optional. The default value is text.align_center. Possible values: text.align_top, text.align_center, text.align_bottom.
    text_wrap (series string): Defines whether the text is presented in a single line, extending past the width of the box if necessary, or wrapped so every line is no wider than the box itself (and clipped by the bottom border of the box if the height of the resulting wrapped text is higher than the height of the box). Optional. The default value is text.wrap_none. Possible values: text.wrap_none, text.wrap_auto.
    text_font_family (series string): The font family of the text. Optional. The default value is font.family_default. Possible values: font.family_default, font.family_monospace.

Box
  Fields:
    left_top (Point): top-left corner of the box
    right_bottom (Point): bottom-right corner of the box
    txt (series string): The text to be displayed inside the box. Optional. The default is empty string.
    args (BoxArgs): Wrapper for reusable arguments for box.new()
    text_args (BoxTextArgs)
    plot (series box): The box object to be added and plotted via draw()

Triangle
  Fields:
    a (Point): first Corner
    b (Point): second Corner
    c (Point): third Corner
    args (LineArgs): Wrapper for reusable arguments for line.new()
    plot_ab (series line): The line object to be added and plotted via draw()
    plot_ac (series line): The line object to be added and plotted via draw()
    plot_bc (series line): The line object to be added and plotted via draw()

TriangleFill
  Fields:
    triangle (Triangle): The Triangle object
    fill_color (series color): The color used to fill the space between the lines.
    plot (series linefill): The linefill object to be added and plotted via draw()

Polygon
  Fields:
    points (Point[]): array of points that make up the Polygon
    center (Point): Center point of the Polygon, can be used for a label and will be center for PolygonFill
    args (LineArgs): Wrapper for reusable arguments for line.new()
    plot (line[]): An array of Lines that form Polygon Border

PolygonFill
  Fields:
    poly (Polygon): the Polygon
    fill_color (series color): The color used to fill the space between the lines.
    plot_segments (line[]): An array of helper lines to create linefills
    plot_fills (linefill[]): An array of linefills that cover the Polygon surface
版本注释
v2 added fallback for update functions, if no Point defined in composite objects, first update will set it
版本注释
v3 added setters for LineArgs and LabelArgs

Added:
method set_line_color(this, value)
  Namespace types: LineArgs
  Parameters:
    this (LineArgs)
    value (color)

method set_style(this, value)
  Namespace types: LabelArgs
  Parameters:
    this (LabelArgs)
    value (string)

method set_width(this, width)
  Namespace types: LineArgs
  Parameters:
    this (LineArgs)
    width (int)

method set_extend(this, extend)
  Namespace types: LineArgs
  Parameters:
    this (LineArgs)
    extend (string)

method set_text_color(this, value)
  Namespace types: LabelArgs
  Parameters:
    this (LabelArgs)
    value (color)

method set_bg_color(this, value)
  Namespace types: LabelArgs
  Parameters:
    this (LabelArgs)
    value (color)

method set_yloc(this, yloc)
  Namespace types: LabelArgs
  Parameters:
    this (LabelArgs)
    yloc (string)

method set_size(this, value)
  Namespace types: LabelArgs
  Parameters:
    this (LabelArgs)
    value (string)
版本注释
v4 added method to update label text
版本注释
v5 add draw methods for arrays of all elements

Updated:
method draw(this)
版本注释
v6 speed optimization, converted date_format string param to simple string
版本注释
v7 additional tostring methods
版本注释
v8 added methods to batch update styles of recycled objects via apply_style and LineArgs/LabelArgs/BoxArgs parameters, affects only style and colors

Added:
method apply_style(this, args, text_args)
版本注释
v9 added additional na checks for draw methods
版本注释
v10 added delete methods for builtin object arrays
版本注释
v11 added Candle data and functions

Added:
method is_green(this)
  Namespace types: Candle
  Parameters:
    this (Candle)

method is_red(this)
  Namespace types: Candle
  Parameters:
    this (Candle)

method is_bullish(this)
  Namespace types: Candle
  Parameters:
    this (Candle)

method is_bearish(this)
  Namespace types: Candle
  Parameters:
    this (Candle)

method total_size(this)
  Namespace types: Candle
  Parameters:
    this (Candle)

method body_size(this)
  Namespace types: Candle
  Parameters:
    this (Candle)

method wick_size_top(this)
  Namespace types: Candle
  Parameters:
    this (Candle)

method wick_size_bottom(this)
  Namespace types: Candle
  Parameters:
    this (Candle)

method body_total_ratio(this)
  Namespace types: Candle
  Parameters:
    this (Candle)

create_candle(t, idx, o, h, l, c)
  Parameters:
    t (int)
    idx (int)
    o (float)
    h (float)
    l (float)
    c (float)

Candle
  Fields:
    bar_time (series int): time based x coordinate
    bar_idx (series int): bar index based x coordinate
    o (series float): candle open price
    h (series float): candle highest price
    l (series float): candle lowest price
    c (series float): candle close price
版本注释
v12 added Candle.direction()
版本注释
v13 added CenterLabel, with reference to a set of points and auto-updated generated center point
added enqueue functions for objects with max amount of items and auto-removal of excess items

Added:
method create_center_label(this, txt, args, tooltip)
  Namespace types: Line
  Parameters:
    this (Line)
    txt (string)
    args (LabelArgs)
    tooltip (string)

CenterLabel
  Fields:
    points (Point[]): The coordinates around the center
    center_label (Label): The generated, centered Label
版本注释
v14 export enqueue functions
版本注释
v15 added update of generated center point into draw function of CenterLabel for convenience
版本注释
v16 fixed error in Candle.tostring()
版本注释
v17 fixed LineFill to create support line for fills between continuous line patterns (end of first is start of next line, where both lines for a linefill should be originating from the same point / headed in the same direction)

Updated:
LineFill
  Fields:
    a (Line): The first Line object
    b (Line): The second Line object
    fill_color (series color): The color used to fill the space between the lines.
    plot (series linefill): The linefill object to be added and plotted via draw()
    support (Line)
版本注释
v18 removed debugging plot
版本注释
v19 added enqueue() for Point[]
版本注释
v20 added volume (v) to Candles
版本注释
v21 added time_close to Candle
版本注释
v22 added body_top and body_bottom
版本注释
v23

Added:
method extend_to(this, end_time, end_idx, end_price)
  Namespace types: Line
  Parameters:
    this (Line)
    end_time (int)
    end_idx (int)
    end_price (float)
版本注释
v24 added nz methods for all object types, providing null objects. added default values to Point/Candle, added methods to create Line and Box from coordinates

Added:
method nz(this, default)
  Namespace types: PolygonFill
  Parameters:
    this (PolygonFill)
    default (PolygonFill)

Updated:
create_line(start_time, start_idx, start_price, end_time, end_idx, end_price, xloc, args)
  Parameters:
    start_time (int)
    start_idx (int)
    start_price (float)
    end_time (int)
    end_idx (int)
    end_price (float)
    xloc (string)
    args (LineArgs)

create_box(left_time, left_idx, top, right_time, right_idx, bottom, xloc, txt, args, text_args)
  Parameters:
    left_time (int)
    left_idx (int)
    top (float)
    right_time (int)
    right_idx (int)
    bottom (float)
    xloc (string)
    txt (string)
    args (BoxArgs)
    text_args (BoxTextArgs)
版本注释
v25 added default param extend_only:true to draw() methods for Lines' x1 and Boxes' left edge coordinates, which prevents accessing old bar_indexes for drawing and therefore triggering max_bars_back errors.
版本注释
v26 replaced custom Point type with new builtin chart.point
revert to this version for Triangles and Polygons, will be extracted to lib_plot_composite_objects
版本注释
v27 extracted Triangle and Polygon functions to separate lib_plot_composite_objects due to size limitations in recent projects
版本注释
v28 exporting extra draw function for builtin line objects
版本注释
v29 updated demo, fixed some chart.point related issues
版本注释
v30 updated batch drawing methods
版本注释
v31 - added some na checks
版本注释
v32 enhanced create_fill() to take an optional support line for triangle creation via chart.points
版本注释
v33 added hide methods, refactored plotting support lines for LineFills
method hide(this)
  Namespace types: Box
  Parameters:
    this (Box)
版本注释
v34 Renamed set_text_color to set_txt_color to avoid overload warning
版本注释
v35 fixed fill not extended for Linefills that require a support line
版本注释
v36 refactored support for flipped line direction in linefill.

Updated:
method create_fill(this, other, fill_color, flip)
LineFill
  Fields:
    a (Line): The first Line object
    b (Line): The second Line object
    fill_color (series color): The color used to fill the space between the lines.
    flip_support (Line): An additional Line that holds a flipped b support line (linefills are always drawn between line starts and line ends)
    plot (series linefill): The linefill object to be added and plotted via draw()

See problem here:
linefill test
版本注释
v37
  • set default colors to fixed values instead of chart.fg_color (created issues when used via securities)
  • added wrapper for polyline -> Polyline (however, polyline is lacking setters, so there's not much performance gain, points cannot be replaced, requires redraw when updating it)
  • added speed optimization 'needs_redraw' flag to address polyline's lacking selective update, and to reduce all plots to absolute minimum (needs to be triggered explicitly). But composite objects like CenterLabel can infer redraw requirement from source object (as long as it isn't reset via draw() before the CenterLabel.update() call)
  • replaced CenterLabel.points with source_line and source_polyline (either or can be set and will be used to update the point of the center_label)
  • added methods around PolyLine (create_center_label, create_center, create_polyline, enqueue, delete
  • added force_redraw parameter to all draw() functions to override needs_redraw
  • removed setters for most objects, just use the direct assignment, save some lib size and context switching on function call
  • removed object inspection part, i.e. tostring() functions, just bloatware for this lib
  • removed workaround for chart.point.now() and chart.point.new() that returned the same chart.point instance on different calls when initialized with the same coordinates. TV fixed it, thank you guys!
  • refactored LineFill draw(), will only draw if one line component has needs_redraw


Added:
method create_polyline(this, curved, closed, args)
  Namespace types: array<chart.point>
  Parameters:
    this (array<chart.point>)
    curved (bool)
    closed (bool)
    args (PolyLineArgs)

PolyLineArgs
  Fields:
    line_color (series color): The color of the line segments. Optional. The default is color.gray.
    fill_color (series color): The fill color of the polyline. Optional. The default is na.
    style (series string): The style of the polyline. Possible values: line.style_solid, line.style_dotted, line.style_dashed, line.style_arrow_left, line.style_arrow_right, line.style_arrow_both. Optional. The default is line.style_solid.
    width (series int): The width of the line segments, expressed in pixels. Optional. The default is 1.
    xloc (series string): Determines the field of the chart.point objects in the points array that the polyline will use for its x-coordinates. If xloc.bar_index, the polyline will use the index field from each point. If xloc.bar_time, it will use the time field. Optional. The default is xloc.bar_index.

PolyLine
  Fields:
    points (array<chart.point>): point array data of the polyline
    curved (series bool): Line color. If true, the drawing will connect all points from the points array using curved line segments. Optional. The default is false.
    closed (series bool): Line color. If true, the drawing will also connect the first point to the last point from the points array, resulting in a closed polyline. Optional. The default is false.
    args (PolyLineArgs): Wrapper for reusable arguments for line.new()
    needs_redraw (series bool)
    plot (series polyline): The polyline object to be added and plotted via draw()

Updated:
method create_center(this)
  Namespace types: PolyLine
  Parameters:
    this (PolyLine)

method create_center_label(this, txt, args, tooltip)
  Creates a new Label object.
  Namespace types: PolyLine
  Parameters:
    this (PolyLine)
    txt (string)
    args (LabelArgs)
    tooltip (string)

method enqueue(id, item, max)
  Namespace types: array<PolyLine>
  Parameters:
    id (array<PolyLine>)
    item (PolyLine)
    max (int)


CenterLabel
  Fields:
    center_label (Label): The generated, centered Label
    source_line (Line)
    source_polyline (PolyLine)
    needs_redraw (series bool)

Removed:
  • method set_line_color(this, value)
  • method set_style(this, value)
  • method set_width(this, width)
  • method set_extend(this, extend)
  • method set_txt_color(this, value)
  • method set_bg_color(this, value)
  • method set_yloc(this, yloc)
  • method set_size(this, value)
  • method tostring(this, date_format)
  • create_point_var(id, bar_time, bar_idx, price)
版本注释
v38 refactored needs_redraw to points_updated, since draw will only update positions, not styles, added center calculation for PolyLines

Added:
method calculate_center(this)
  Namespace types: PolyLine
  Parameters:
    this (PolyLine)
版本注释
v39 removed points_updated status (intended for drawing/plotting optimization): however, pine does not support selective drawing/plotting only during certain ticks where values changed (native plot objects may not be used as varip). Therefore the best approach to optimize script run times is to optimize value/coordinate calculation (remain after change inside bar, use varip) then set the coordinates on each iteration (redundant but necessary since pine is rolling back plots between ticks, using (var))

Usage:
版本注释
v40 added factory methods without coordinates, added force_overlay capability in factory methods, now removing deleted plots from object so they can be re-painted if necessary,

Updated:
create_label(txt, args, tooltip, init_plot, force_overlay)
  Parameters:
    txt (string)
    args (LabelArgs)
    tooltip (string)
    init_plot (bool)
    force_overlay (bool)

method create_center_label(this, txt, args, tooltip, init_plot, force_overlay)
  Creates a new Label object.
  Namespace types: PolyLine
  Parameters:
    this (PolyLine)
    txt (string)
    args (LabelArgs)
    tooltip (string)
    init_plot (bool)
    force_overlay (bool)

create_line(args, init_plot, force_overlay)
  Parameters:
    args (LineArgs)
    init_plot (bool)
    force_overlay (bool)

method create_polyline(this, curved, closed, args, init_plot, force_overlay)
  Namespace types: array<chart.point>
  Parameters:
    this (array<chart.point>)
    curved (bool)
    closed (bool)
    args (PolyLineArgs)
    init_plot (bool)
    force_overlay (bool)

create_box(txt, args, text_args, init_plot, force_overlay)
  Parameters:
    txt (string)
    args (BoxArgs)
    text_args (BoxTextArgs)
    init_plot (bool)
    force_overlay (bool)

method create_fill(this, other, fill_color, flip, init_flip_plot, force_overlay)
  Namespace types: Line
  Parameters:
    this (Line)
    other (Line)
    fill_color (color)
    flip (bool)
    init_flip_plot (bool)
    force_overlay (bool)
版本注释
v41 added deep copy functions for Label/CenterLabel/Line/Box to clone objects including the plot/chart object (polyline has no native copy function, you'll have to recreate it)

Added:
method deep_copy(this)
版本注释
v42 added deep_copy for LineFill

Updated:
method deep_copy(this, copy_references)
  Namespace types: LineFill
  Parameters:
    this (LineFill)
    copy_references (bool)

LineFill
  Fields:
    flip_support_force_overlay (series bool) // required on initialization so deep_copy can pass it to the flip_support Line plot
版本注释
v43 modified linefill deep_copy to create a new plot/chart object instance manually as linefill.copy does not exist, simplified force_overlay handling for flip_support and deep_copy
版本注释
v45 - added na check to deep_copy functions
版本注释
v46
  • updated to pine v6
  • hide(): skipped drawing (updating chart object) if it has not been drawn yet, added example (b3)

版本注释
v47 fixed bug in hide methods, directly setting (right) y coordinates of chart objects to na now INSTEAD OF previously overriding all (right) chart.point data in plot objects and calling draw method again
版本注释
v48 added hidden flag for more efficient processing of already hidden objects

Added:
Label / Line / PolyLine / Box
  Fields:
    hidden (series bool)
版本注释
v49 revert to ternary operators, pine v6 shortcut evaluation still buggy
displaydrawingtoolsecosystemframeworkMarket Geometryobjectsplottingwizardry

Pine脚本库

本着真正的TradingView精神,作者将此Pine代码发布为开源脚本库,以便我们社区的其他Pine程序员可以重复使用它。向作者致敬!您可以私下或在其它开源出版物中使用此脚本库,但在出版物中重复使用此代码受网站规则约束。

免责声明