Language version: 2 · Reference version: 2.7 · Date: 2026-10-25 · Compiler build: df7b3b14 · Namespace: box · Entries: 32
box (library)
Definition
Functions for creating and mutating rectangular box drawings on the chart.
box.new text options use size, textcolor, texthalign, textvalign, textwrap, and text_font_family; setters keep the box.set_text_* names.
Notes
- A
box.<name>(b, ...)function can also be called on the box asb.<name>(...), for exampleb.set_right(bar_index).
box.all (function)
Definition
Returns the array of all existing box objects (same as box.all).
Syntax
series array<box>
An array of box IDs, oldest to newest.
Example
box.copy (function)
Definition
Creates a copy of a box.
Syntax
Returns
series box
The new box ID.
Example
box.delete (function)
Definition
Deletes a box.
Syntax
Returns
void
void
Example
box.get_bottom (function)
Definition
Returns the bottom price of a box.
Syntax
Returns
series float
Bottom y-coordinate.
Example
box.get_left (function)
Definition
Returns the left x-coordinate of a box.
Syntax
Returns
series int
Left x-coordinate.
Example
box.get_right (function)
Definition
Returns the right x-coordinate of a box.
Syntax
Returns
series int
Right x-coordinate.
Example
box.get_top (function)
Definition
Returns the top price of a box.
Syntax
Returns
series float
Top y-coordinate.
Example
box.new (function, overload 1)
Definition
Creates a box from left/top/right/bottom coordinates, or from two chartPoint corners.
Text styling uses size, textcolor, texthalign, textvalign, textwrap, and text_font_family (typed size and font enums where noted).
Syntax
Returns
series box
The ID of the created box.
Notes
- The
sizeargument takes asize.*constant (size.auto,size.tiny,size.small,size.normal,size.large,size.huge). A string such as “small” still compiles, with a deprecation warning: write the constant. - The old names
text_color,text_halign,text_valign,text_sizeandtext_wrapstill compile, with a deprecation warning that names the new spelling (textcolor,texthalign,textvalign,size,textwrap). Giving both spellings of one argument is an error. Write the new names. - A string that is not a size name, such as “giant”, stops the compiler with the error “internal validator error”: write a
size.*constant. - The two forms have different default colors. Given
left,top,rightandbottom,border_color,bgcolorandtextcolordefault to#483D8B. Given two chartPoint corners,border_colorandbgcolordefault tocolor.blueandtextcolortocolor.white.
box.new (function, overload 2)
Definition
Creates a box from left/top/right/bottom coordinates, or from two chartPoint corners.
Text styling uses size, textcolor, texthalign, textvalign, textwrap, and text_font_family (typed size and font enums where noted).
Syntax
Returns
series box
The ID of the created box.
Notes
- The
sizeargument takes asize.*constant (size.auto,size.tiny,size.small,size.normal,size.large,size.huge). A string such as “small” still compiles, with a deprecation warning: write the constant. - The old names
text_color,text_halign,text_valign,text_sizeandtext_wrapstill compile, with a deprecation warning that names the new spelling (textcolor,texthalign,textvalign,size,textwrap). Giving both spellings of one argument is an error. Write the new names. - A string that is not a size name, such as “giant”, stops the compiler with the error “internal validator error”: write a
size.*constant. - The two forms have different default colors. Given
left,top,rightandbottom,border_color,bgcolorandtextcolordefault to#483D8B. Given two chartPoint corners,border_colorandbgcolordefault tocolor.blueandtextcolortocolor.white.
box.set_bgcolor (function)
Definition
Sets a box’s background color.
Syntax
Returns
void
void
Example
box.set_border_color (function)
Definition
Sets a box’s border color.
Syntax
Returns
void
void
Example
box.set_border_style (function)
Definition
Sets a box’s border style.
Syntax
Returns
void
void
Example
box.set_border_width (function)
Definition
Sets a box’s border width in pixels.
Syntax
Returns
void
void
Example
box.set_bottom (function)
Definition
Sets a box’s bottom price.
Syntax
Returns
void
void
Example
box.set_bottom_right_point (function)
Definition
Sets a box’s bottom-right corner from a chartPoint.
Syntax
Returns
void
void
Example
box.set_extend (function)
Definition
Sets whether a box extends past its corners.
Syntax
Returns
void
void
Example
box.set_left (function)
Definition
Sets a box’s left x-coordinate.
Syntax
Returns
void
void
Example
box.set_lefttop (function)
Definition
Sets a box’s left x-coordinate and top price.
Syntax
Returns
void
void
Example
box.set_right (function)
Definition
Sets a box’s right x-coordinate.
Syntax
Returns
void
void
Example
box.set_rightbottom (function)
Definition
Sets a box’s right x-coordinate and bottom price.
Syntax
Returns
void
void
Example
box.set_text (function)
Definition
Sets a box’s text.
Syntax
Returns
void
void
Example
box.set_text_color (function)
Definition
Sets a box’s text color.
Syntax
Returns
void
void
Example
box.set_text_font_family (function)
Definition
Sets a box’s text font family.
Syntax
Returns
void
void
Example
box.set_text_formatting (function)
Definition
Sets a box’s text formatting.
Syntax
Returns
void
void
Example
box.set_text_halign (function)
Definition
Sets a box’s horizontal text alignment.
Syntax
Returns
void
void
Example
box.set_text_size (function)
Definition
Sets a box’s text size.
Syntax
Returns
void
void
Notes
- The
sizeargument takes asize.*constant (size.auto,size.tiny,size.small,size.normal,size.large,size.huge). A string such as “small” still compiles, with a deprecation warning: write the constant.
box.set_text_valign (function)
Definition
Sets a box’s vertical text alignment.
Syntax
Returns
void
void
Example
box.set_text_wrap (function)
Definition
Sets whether a box’s text wraps.
Syntax
Returns
void
void
Example
box.set_top (function)
Definition
Sets a box’s top price.
Syntax
Returns
void
void
Example
box.set_top_left_point (function)
Definition
Sets a box’s top-left corner from a chartPoint.
Syntax
Returns
void
void
Example
box.set_xloc (function)
Definition
Sets whether a box’s x-coordinates are bar indexes or times.
Syntax
Returns
void
void
Example