Skip to content

box

Properties

all

Type: series array<box>

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

Functions

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 stringline.style_solidThe border line style.
extendseries stringextend.noneThe extension mode: extend.none, extend.left, extend.right, or extend.both.
xlocseries stringxloc.bar_indexThe x-location type: xloc.bar_index or xloc.bar_time.
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 stringtext.align_rightThe horizontal text alignment.
text_valignseries stringtext.align_centerThe vertical text alignment.
text_wrapseries stringtext.wrap_noneThe text wrapping mode.
text_font_familyseries stringfont.family_defaultThe font family for the text.
force_overlayconst boolfalseIf true, the box is rendered on top.
text_formattingconst text_formattext.format_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 stringline.style_solidThe border line style.
extendseries stringextend.noneThe extension mode: extend.none, extend.left, extend.right, or extend.both.
xlocseries stringxloc.bar_indexThe x-location type: xloc.bar_index or xloc.bar_time.
bgcolorseries colorcolor.blueThe background color of the box.
textseries string""The text content of the box.
text_sizeseries stringsize.autoThe text size as a named constant.
text_colorseries colorcolor.blackThe text color.
text_halignseries stringtext.align_rightThe horizontal text alignment.
text_valignseries stringtext.align_centerThe vertical text alignment.
text_wrapseries stringtext.wrap_noneThe text wrapping mode.
text_font_familyseries stringfont.family_defaultThe font family for the text.
force_overlayconst boolfalseIf true, the box is rendered on top.
text_formattingconst text_formattext.format_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 stringline.style_solidThe border line style.
extendseries stringextend.noneThe extension mode: extend.none, extend.left, extend.right, or extend.both.
xlocseries stringxloc.bar_indexThe x-location type: xloc.bar_index or xloc.bar_time.
bgcolorseries colorcolor.blueThe background color of the box.
textseries string""The text content of the box.
text_sizeseries intsize.autoThe text size in pixels.
text_colorseries colorcolor.blackThe text color.
text_halignseries stringtext.align_rightThe horizontal text alignment.
text_valignseries stringtext.align_centerThe vertical text alignment.
text_wrapseries stringtext.wrap_noneThe text wrapping mode.
text_font_familyseries stringfont.family_defaultThe font family for the text.
force_overlayconst boolfalseIf true, the box is rendered on top.
text_formattingconst text_formattext.format_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 stringline.style_solidThe border line style.
extendseries stringextend.noneThe extension mode: extend.none, extend.left, extend.right, or extend.both.
xlocseries stringxloc.bar_indexThe x-location type: xloc.bar_index or xloc.bar_time.
bgcolorseries colorcolor.blueThe background color of the box.
textseries string""The text content of the box.
text_sizeseries stringsize.autoThe text size as a named constant.
text_colorseries colorcolor.blackThe text color.
text_halignseries stringtext.align_rightThe horizontal text alignment.
text_valignseries stringtext.align_centerThe vertical text alignment.
text_wrapseries stringtext.wrap_noneThe text wrapping mode.
text_font_familyseries stringfont.family_defaultThe font family for the text.
force_overlayconst boolfalseIf true, the box is rendered on top.
text_formattingconst text_formattext.format_noneThe text formatting options.

Returns: series box

Methods

copy

pine
box.copy(series box id) → series box

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

Parameters

NameTypeDefaultDescription
idseries boxThe box to copy.

Returns: series box


delete

pine
box.delete(series box id)

Deletes the specified box from the chart.

Parameters

NameTypeDefaultDescription
idseries boxThe box to delete.

get_bottom

pine
box.get_bottom(series box id) → 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

pine
box.get_left(series box id) → 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

pine
box.get_right(series box id) → 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

pine
box.get_top(series box id) → 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_bgcolor

pine
box.set_bgcolor(series box id, series color color)

Sets the background color of the box.

Parameters

NameTypeDefaultDescription
idseries boxThe box to modify.
colorseries colorThe new background color.

set_border_color

pine
box.set_border_color(series box id, series color color)

Sets the border color of the box.

Parameters

NameTypeDefaultDescription
idseries boxThe box to modify.
colorseries colorThe new border color.

set_border_style

pine
box.set_border_style(series box id, series string style)

Sets the border style of the box.

Parameters

NameTypeDefaultDescription
idseries boxThe box to modify.
styleseries stringThe new border line style.

set_border_width

pine
box.set_border_width(series box id, series int width)

Sets the border width of the box.

Parameters

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

set_bottom

pine
box.set_bottom(series box id, series float bottom)

Sets the bottom coordinate of the box.

Parameters

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

set_bottom_right_point

pine
box.set_bottom_right_point(series box id, series chart.point 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

pine
box.set_extend(series box id, series string extend)

Sets extending type of the border of this box object.

Parameters

NameTypeDefaultDescription
idseries boxThe box to modify.
extendseries stringThe extension mode: extend.none, extend.left, extend.right, or extend.both.

set_left

pine
box.set_left(series box id, series int left)

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

pine
box.set_lefttop(series box id, series int left, series float top)

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

pine
box.set_right(series box id, series int right)

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

pine
box.set_rightbottom(series box id, series int right, series float bottom)

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

pine
box.set_text(series box id, series string text)

Sets the text size of the box.

Parameters

NameTypeDefaultDescription
idseries boxThe box to modify.
textseries stringThe new text content.

set_text_color

pine
box.set_text_color(series box id, series color text_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

pine
box.set_text_font_family(series box id, series string font_family)

Sets the font family of the box text.

Parameters

NameTypeDefaultDescription
idseries boxThe box to modify.
font_familyseries stringThe font family: font.family_default or font.family_monospace.

set_text_formatting

pine
box.set_text_formatting(series box id, const text_format text_formatting)

Sets the text formatting of the box.

Parameters

NameTypeDefaultDescription
idseries boxThe box to modify.
text_formattingconst text_formatThe text formatting options.

set_text_halign

pine
box.set_text_halign(series box id, series string text_halign)

Sets the horizontal alignment of the box text.

Parameters

NameTypeDefaultDescription
idseries boxThe box to modify.
text_halignseries stringThe horizontal text alignment: text.align_left, text.align_center, or text.align_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 stringThe new text size as a named constant (size.tiny, size.small, size.normal, size.large, size.huge).

set_text_valign

pine
box.set_text_valign(series box id, series string text_valign)

Sets the vertical alignment of the box text.

Parameters

NameTypeDefaultDescription
idseries boxThe box to modify.
text_valignseries stringThe vertical text alignment: text.align_top, text.align_center, or text.align_bottom.

set_text_wrap

pine
box.set_text_wrap(series box id, series string text_wrap)

Sets the text wrapping mode of the box.

Parameters

NameTypeDefaultDescription
idseries boxThe box to modify.
text_wrapseries stringThe text wrapping mode: text.wrap_none or text.wrap_auto.

set_top

pine
box.set_top(series box id, series float top)

Sets the top coordinate of the box.

Parameters

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

set_top_left_point

pine
box.set_top_left_point(series box id, series chart.point 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

pine
box.set_xloc(
    series box id,
    series int left,
    series int right,
    series string 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 stringThe x-location type: xloc.bar_index or xloc.bar_time.

基于 MIT 许可证发布。