Skip to content

Box ​

Handle for a box drawing.

Static Methods ​

new ​

Creates a new box object.

Parameters

NameTypeDefaultDescription
leftseries intThe left coordinate (bar index or UNIX time).
topseries floatThe top coordinate (price).
rightseries intThe right coordinate (bar index or UNIX time).
bottomseries floatThe bottom coordinate (price).
border_colorseries ColorColor.BLUEThe border color of the box.
border_widthseries int1The border width in pixels.
border_styleseries LineStyleLineStyle.SolidThe border line style.
extendseries ExtendExtend.NoneThe extension mode: Extend.None, Extend.Left, Extend.Right, or Extend.Both.
xlocseries XLocXLoc.BarIndexThe x-location type: XLoc.BarIndex or XLoc.BarTime.
bg_colorseries ColorColor.BLUEThe background color of the box.
textseries StringnaThe text content of the box.
text_sizeseries int0The text size in pixels.
text_colorseries ColorColor.BLACKThe text color.
text_halignseries TextHAlignTextHAlign.CenterThe horizontal text alignment.
text_valignseries TextVAlignTextVAlign.CenterThe vertical text alignment.
text_wrapseries TextWrapTextWrap.NoneThe text wrapping mode.
text_font_familyseries FontFamilyFontFamily.DefaultThe font family for the text.
force_overlayconst boolfalseIf true, the box is rendered on top.
text_formattingconst TextFormatTextFormat.NONEThe text formatting options.

Returns: series Box

Creates a new box object.

Parameters

NameTypeDefaultDescription
leftseries intThe left coordinate (bar index or UNIX time).
topseries floatThe top coordinate (price).
rightseries intThe right coordinate (bar index or UNIX time).
bottomseries floatThe bottom coordinate (price).
border_colorseries ColorColor.BLUEThe border color of the box.
border_widthseries int1The border width in pixels.
border_styleseries LineStyleLineStyle.SolidThe border line style.
extendseries ExtendExtend.NoneThe extension mode: Extend.None, Extend.Left, Extend.Right, or Extend.Both.
xlocseries XLocXLoc.BarIndexThe x-location type: XLoc.BarIndex or XLoc.BarTime.
bg_colorseries ColorColor.BLUEThe background color of the box.
textseries StringnaThe text content of the box.
text_sizeseries SizeSize.AutoThe text size as a named constant.
text_colorseries ColorColor.BLACKThe text color.
text_halignseries TextHAlignTextHAlign.CenterThe horizontal text alignment.
text_valignseries TextVAlignTextVAlign.CenterThe vertical text alignment.
text_wrapseries TextWrapTextWrap.NoneThe text wrapping mode.
text_font_familyseries FontFamilyFontFamily.DefaultThe font family for the text.
force_overlayconst boolfalseIf true, the box is rendered on top.
text_formattingconst TextFormatTextFormat.NONEThe text formatting options.

Returns: series Box

Creates a new box object.

Parameters

NameTypeDefaultDescription
top_leftseries chart.PointThe chart.Point object specifying the top-left corner.
bottom_rightseries chart.PointThe chart.Point object specifying the bottom-right corner.
border_colorseries ColorColor.BLUEThe border color of the box.
border_widthseries int1The border width in pixels.
border_styleseries LineStyleLineStyle.SolidThe border line style.
extendseries ExtendExtend.NoneThe extension mode: Extend.None, Extend.Left, Extend.Right, or Extend.Both.
xlocseries XLocXLoc.BarIndexThe x-location type: XLoc.BarIndex or XLoc.BarTime.
bg_colorseries ColorColor.BLUEThe background color of the box.
textseries StringnaThe text content of the box.
text_sizeseries SizeSize.AutoThe text size in pixels.
text_colorseries ColorColor.BLACKThe text color.
text_halignseries TextHAlignTextHAlign.CenterThe horizontal text alignment.
text_valignseries TextVAlignTextVAlign.CenterThe vertical text alignment.
text_wrapseries TextWrapTextWrap.NoneThe text wrapping mode.
text_font_familyseries FontFamilyFontFamily.DefaultThe font family for the text.
force_overlayconst boolfalseIf true, the box is rendered on top.
text_formattingconst TextFormatTextFormat.NONEThe text formatting options.

Returns: series Box

Creates a new box object.

Parameters

NameTypeDefaultDescription
top_leftseries chart.PointThe chart.Point object specifying the top-left corner.
bottom_rightseries chart.PointThe chart.Point object specifying the bottom-right corner.
border_colorseries ColorColor.BLUEThe border color of the box.
border_widthseries int1The border width in pixels.
border_styleseries LineStyleLineStyle.SolidThe border line style.
extendseries ExtendExtend.NoneThe extension mode: Extend.None, Extend.Left, Extend.Right, or Extend.Both.
xlocseries XLocXLoc.BarIndexThe x-location type: XLoc.BarIndex or XLoc.BarTime.
bg_colorseries ColorColor.BLUEThe background color of the box.
textseries StringnaThe text content of the box.
text_sizeseries SizeSize.AutoThe text size as a named constant.
text_colorseries ColorColor.BLACKThe text color.
text_halignseries TextHAlignTextHAlign.CenterThe horizontal text alignment.
text_valignseries TextVAlignTextVAlign.CenterThe vertical text alignment.
text_wrapseries TextWrapTextWrap.NoneThe text wrapping mode.
text_font_familyseries FontFamilyFontFamily.DefaultThe font family for the text.
force_overlayconst boolfalseIf true, the box is rendered on top.
text_formattingconst TextFormatTextFormat.NONEThe text formatting options.

Returns: series Box

Static Properties ​

all ​

Type: series Array<Box>

Returns an array filled with all the current boxes drawn by the script.

Methods ​

copy ​

navi
copy(id: series Box): series Box

Creates a copy of the specified box and returns its id.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to copy.

Returns: series Box


delete ​

navi
delete(id: series Box)

Deletes the specified box from the chart.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to delete.

get_bottom ​

navi
get_bottom(id: series Box): series float

Returns the price value of the bottom border of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to get the bottom coordinate from.

Returns: series float


get_left ​

navi
get_left(id: series Box): series int

Returns the bar index or the UNIX time (depending on the last value used for 'xloc') of the left border of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to get the left coordinate from.

Returns: series int


get_right ​

navi
get_right(id: series Box): series int

Returns the bar index or the UNIX time (depending on the last value used for 'xloc') of the right border of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to get the right coordinate from.

Returns: series int


get_top ​

navi
get_top(id: series Box): series float

Returns the price value of the top border of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to get the top coordinate from.

Returns: series float


set_bg_color ​

navi
set_bg_color(id: series Box, color: series Color)

Sets the background color of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
colorseries ColorThe new background color.

set_border_color ​

navi
set_border_color(id: series Box, color: series Color)

Sets the border color of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
colorseries ColorThe new border color.

set_border_style ​

navi
set_border_style(id: series Box, style: series LineStyle)

Sets the border style of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
styleseries LineStyleThe new border line style.

set_border_width ​

navi
set_border_width(id: series Box, width: series int)

Sets the border width of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
widthseries intThe new border width in pixels.

set_bottom ​

navi
set_bottom(id: series Box, bottom: series float)

Sets the bottom coordinate of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
bottomseries floatThe new bottom coordinate (price).

set_bottom_right_point ​

navi
set_bottom_right_point(id: series Box, point: series chart.Point)

Sets the bottom-right corner of the box using a chart.Point object.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
pointseries chart.PointThe chart.Point object specifying the new bottom-right corner.

set_extend ​

navi
set_extend(id: series Box, extend: series Extend)

Sets extending type of the border of this box object.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
extendseries ExtendThe extension mode: Extend.None, Extend.Left, Extend.Right, or Extend.Both.

set_left ​

navi
set_left(id: series Box, left: series int)

Sets the left coordinate of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
leftseries intThe new left coordinate (bar index or UNIX time).

set_left_top ​

navi
set_left_top(id: series Box, left: series int, top: series float)

Sets the left and top coordinates of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
leftseries intThe new left coordinate (bar index or UNIX time).
topseries floatThe new top coordinate (price).

set_right ​

navi
set_right(id: series Box, right: series int)

Sets the right coordinate of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
rightseries intThe new right coordinate (bar index or UNIX time).

set_right_bottom ​

navi
set_right_bottom(id: series Box, right: series int, bottom: series float)

Sets the right and bottom coordinates of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
rightseries intThe new right coordinate (bar index or UNIX time).
bottomseries floatThe new bottom coordinate (price).

set_text ​

navi
set_text(id: series Box, text: series String)

Sets the text size of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
textseries StringThe new text content.

set_text_color ​

navi
set_text_color(id: series Box, text_color: series Color)

Sets the text color of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
text_colorseries ColorThe new text color.

set_text_font_family ​

Sets the font family of the box text.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
font_familyseries FontFamilyThe font family: FontFamily.Default or FontFamily.Monospace.

Sets the font family of the box text, by name.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
font_familyseries StringThe font family: "default" or "monospace". Kept so a script that spells the value out keeps working; new code should pass FontFamily.

set_text_formatting ​

navi
set_text_formatting(id: series Box, text_formatting: const TextFormat)

Sets the text formatting of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
text_formattingconst TextFormatThe text formatting options.

set_text_halign ​

navi
set_text_halign(id: series Box, text_halign: series TextHAlign)

Sets the horizontal alignment of the box text.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
text_halignseries TextHAlignThe horizontal text alignment: TextHAlign.Left, TextHAlign.Center, or TextHAlign.Right.

set_text_size ​

Sets the text size of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
text_sizeseries intThe new text size in pixels.

Sets the text size of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
text_sizeseries SizeThe new text size as a named constant (Size.Tiny, Size.Small, Size.Normal, Size.Large, Size.Huge).

set_text_valign ​

navi
set_text_valign(id: series Box, text_valign: series TextVAlign)

Sets the vertical alignment of the box text.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
text_valignseries TextVAlignThe vertical text alignment: TextVAlign.Top, TextHAlign.Center, or TextVAlign.Bottom.

set_text_wrap ​

navi
set_text_wrap(id: series Box, text_wrap: series TextWrap)

Sets the text wrapping mode of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
text_wrapseries TextWrapThe text wrapping mode: TextWrap.None or TextWrap.Auto.

set_top ​

navi
set_top(id: series Box, top: series float)

Sets the top coordinate of the box.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
topseries floatThe new top coordinate (price).

set_top_left_point ​

navi
set_top_left_point(id: series Box, point: series chart.Point)

Sets the top-left corner of the box using a chart.Point object.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
pointseries chart.PointThe chart.Point object specifying the new top-left corner.

set_xloc ​

navi
set_xloc(id: series Box, left: series int, right: series int, xloc: series XLoc)

Sets the left and right borders of a box and updates its xloc property.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to modify.
leftseries intThe new left coordinate (bar index or UNIX time).
rightseries intThe new right coordinate (bar index or UNIX time).
xlocseries XLocThe x-location type: XLoc.BarIndex or XLoc.BarTime.