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 (tradingview.com/script/63c8VXSa-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)
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
Release Notes
â‹…
v2 added fallback for update functions, if no Point defined in composite objects, first update will set it
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
Release Notes
â‹…
v12 added Candle.direction()
Release Notes
â‹…
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
CenterLabel   Fields:     points (Point[]): The coordinates around the center     center_label (Label): The generated, centered Label
Release Notes
â‹…
v14 export enqueue functions
Release Notes
â‹…
v15 added update of generated center point into draw function of CenterLabel for convenience
Release Notes
â‹…
v16 fixed error in Candle.tostring()
Release Notes
â‹…
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)
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
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.
Release Notes
â‹…
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
Release Notes
â‹…
v27 extracted Triangle and Polygon functions to separate lib_plot_composite_objects due to size limitations in recent projects
Release Notes
â‹…
v28 exporting extra draw function for builtin line objects
Release Notes
â‹…
v29 updated demo, fixed some chart.point related issues
Release Notes
â‹…
v30 updated batch drawing methods
Release Notes
â‹…
v31 - added some na checks
Release Notes
â‹…
v32 enhanced create_fill() to take an optional support line for triangle creation via chart.points
Release Notes
â‹…
v33 added hide methods, refactored plotting support lines for LineFills method hide(this)   Namespace types: Box   Parameters:     this (Box)
Release Notes
â‹…
v34 Renamed set_text_color to set_txt_color to avoid overload warning
Release Notes
â‹…
v35 fixed fill not extended for Linefills that require a support line
Release Notes
â‹…
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()