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.
bgcolorseries colorcolor.BLUEThe background color of the box.
textseries string""The text content of the box.
text_sizeseries int0The text size in pixels.
text_colorseries colorcolor.BLACKThe text color.
text_halignseries TextHAlignTextHAlign.RightThe 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 TextFormattext.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.
bgcolorseries colorcolor.BLUEThe background color of the box.
textseries string""The text content of the box.
text_sizeseries SizeSize.AutoThe text size as a named constant.
text_colorseries colorcolor.BLACKThe text color.
text_halignseries TextHAlignTextHAlign.RightThe 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 TextFormattext.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.
bgcolorseries colorcolor.BLUEThe background color of the box.
textseries string""The text content of the box.
text_sizeseries SizeSize.AutoThe text size in pixels.
text_colorseries colorcolor.BLACKThe text color.
text_halignseries TextHAlignTextHAlign.RightThe 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 TextFormattext.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.
bgcolorseries colorcolor.BLUEThe background color of the box.
textseries string""The text content of the box.
text_sizeseries SizeSize.AutoThe text size as a named constant.
text_colorseries colorcolor.BLACKThe text color.
text_halignseries TextHAlignTextHAlign.RightThe 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 TextFormattext.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
Box.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
Box.delete(id: series Box)

Deletes the specified box from the chart.

Parameters

NameTypeDefaultDescription
idseries BoxThe box to delete.

get_bottom

navi
Box.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
Box.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
Box.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
Box.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
Box.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
Box.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
Box.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
Box.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
Box.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
Box.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
Box.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
Box.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_lefttop

navi
Box.set_lefttop(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
Box.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_rightbottom

navi
Box.set_rightbottom(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
Box.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
Box.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

navi
Box.set_text_font_family(id: series Box, font_family: series string)

Sets the font family of the box text.

Parameters

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

set_text_formatting

navi
Box.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
Box.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
Box.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
Box.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
Box.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
Box.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
Box.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.

Released under the MIT License.