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)
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 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
Informacje o Wersji
⋅
v2 added fallback for update functions, if no Point defined in composite objects, first update will set it
Informacje o Wersji
⋅
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_size(this, value) Namespace types: LabelArgs Parameters: this (LabelArgs) value (string)
Informacje o Wersji
⋅
v4 added method to update label text
Informacje o Wersji
⋅
v5 add draw methods for arrays of all elements
Updated: method draw(this)
Informacje o Wersji
⋅
v6 speed optimization, converted date_format string param to simple string
Informacje o Wersji
⋅
v7 additional tostring methods
Informacje o Wersji
⋅
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)
Informacje o Wersji
⋅
v9 added additional na checks for draw methods
Informacje o Wersji
⋅
v10 added delete methods for builtin object arrays
Informacje o Wersji
⋅
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
Informacje o Wersji
⋅
v12 added Candle.direction()
Informacje o Wersji
⋅
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
Informacje o Wersji
⋅
v14 export enqueue functions
Informacje o Wersji
⋅
v15 added update of generated center point into draw function of CenterLabel for convenience
Informacje o Wersji
⋅
v16 fixed error in Candle.tostring()
Informacje o Wersji
⋅
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)
Informacje o Wersji
⋅
v18 removed debugging plot
Informacje o Wersji
⋅
v19 added enqueue() for Point[]
Informacje o Wersji
⋅
v20 added volume (v) to Candles
Informacje o Wersji
⋅
v21 added time_close to Candle
Informacje o Wersji
⋅
v22 added body_top and body_bottom
Informacje o Wersji
⋅
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)
Informacje o Wersji
⋅
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.
Informacje o Wersji
⋅
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
Informacje o Wersji
⋅
v27 extracted Triangle and Polygon functions to separate lib_plot_composite_objects due to size limitations in recent projects
Informacje o Wersji
⋅
v28 exporting extra draw function for builtin line objects
Informacje o Wersji
⋅
v29 updated demo, fixed some chart.point related issues
Informacje o Wersji
⋅
v30 updated batch drawing methods
Informacje o Wersji
⋅
v31 - added some na checks
Informacje o Wersji
⋅
v32 enhanced create_fill() to take an optional support line for triangle creation via chart.points
Informacje o Wersji
⋅
v33 added hide methods, refactored plotting support lines for LineFills method hide(this) Namespace types: Box Parameters: this (Box)
Informacje o Wersji
⋅
v34 Renamed set_text_color to set_txt_color to avoid overload warning
Informacje o Wersji
⋅
v35 fixed fill not extended for Linefills that require a support line
Informacje o Wersji
⋅
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()