Skip to main content
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 as b.<name>(...), for example b.set_right(bar_index).
Example

box.all (function)

Definition Returns the array of all existing box objects (same as box.all). Syntax
Returns series array<box> An array of box IDs, oldest to newest. Example

box.copy (function)

Definition Creates a copy of a box. Syntax
Parameters Returns series box The new box ID. Example

box.delete (function)

Definition Deletes a box. Syntax
Parameters Returns void void Example

box.get_bottom (function)

Definition Returns the bottom price of a box. Syntax
Parameters Returns series float Bottom y-coordinate. Example

box.get_left (function)

Definition Returns the left x-coordinate of a box. Syntax
Parameters Returns series int Left x-coordinate. Example

box.get_right (function)

Definition Returns the right x-coordinate of a box. Syntax
Parameters Returns series int Right x-coordinate. Example

box.get_top (function)

Definition Returns the top price of a box. Syntax
Parameters 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
Parameters Returns series box The ID of the created box. Notes
  • The size argument takes a size.* 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_size and text_wrap still 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, right and bottom, border_color, bgcolor and textcolor default to #483D8B. Given two chartPoint corners, border_color and bgcolor default to color.blue and textcolor to color.white.
Example

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
Parameters Returns series box The ID of the created box. Notes
  • The size argument takes a size.* 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_size and text_wrap still 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, right and bottom, border_color, bgcolor and textcolor default to #483D8B. Given two chartPoint corners, border_color and bgcolor default to color.blue and textcolor to color.white.
Example

box.set_bgcolor (function)

Definition Sets a box’s background color. Syntax
Parameters Returns void void Example

box.set_border_color (function)

Definition Sets a box’s border color. Syntax
Parameters Returns void void Example

box.set_border_style (function)

Definition Sets a box’s border style. Syntax
Parameters Returns void void Example

box.set_border_width (function)

Definition Sets a box’s border width in pixels. Syntax
Parameters Returns void void Example

box.set_bottom (function)

Definition Sets a box’s bottom price. Syntax
Parameters Returns void void Example

box.set_bottom_right_point (function)

Definition Sets a box’s bottom-right corner from a chartPoint. Syntax
Parameters Returns void void Example

box.set_extend (function)

Definition Sets whether a box extends past its corners. Syntax
Parameters Returns void void Example

box.set_left (function)

Definition Sets a box’s left x-coordinate. Syntax
Parameters Returns void void Example

box.set_lefttop (function)

Definition Sets a box’s left x-coordinate and top price. Syntax
Parameters Returns void void Example

box.set_right (function)

Definition Sets a box’s right x-coordinate. Syntax
Parameters Returns void void Example

box.set_rightbottom (function)

Definition Sets a box’s right x-coordinate and bottom price. Syntax
Parameters Returns void void Example

box.set_text (function)

Definition Sets a box’s text. Syntax
Parameters Returns void void Example

box.set_text_color (function)

Definition Sets a box’s text color. Syntax
Parameters Returns void void Example

box.set_text_font_family (function)

Definition Sets a box’s text font family. Syntax
Parameters Returns void void Example

box.set_text_formatting (function)

Definition Sets a box’s text formatting. Syntax
Parameters Returns void void Example

box.set_text_halign (function)

Definition Sets a box’s horizontal text alignment. Syntax
Parameters Returns void void Example

box.set_text_size (function)

Definition Sets a box’s text size. Syntax
Parameters Returns void void Notes
  • The size argument takes a size.* 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.
Example

box.set_text_valign (function)

Definition Sets a box’s vertical text alignment. Syntax
Parameters Returns void void Example

box.set_text_wrap (function)

Definition Sets whether a box’s text wraps. Syntax
Parameters Returns void void Example

box.set_top (function)

Definition Sets a box’s top price. Syntax
Parameters Returns void void Example

box.set_top_left_point (function)

Definition Sets a box’s top-left corner from a chartPoint. Syntax
Parameters Returns void void Example

box.set_xloc (function)

Definition Sets whether a box’s x-coordinates are bar indexes or times. Syntax
Parameters Returns void void Example