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
| Name | Type | Default | Description |
|---|---|---|---|
left | series int | The left coordinate (bar index or UNIX time). | |
top | series float | The top coordinate (price). | |
right | series int | The right coordinate (bar index or UNIX time). | |
bottom | series float | The bottom coordinate (price). | |
border_color | series color | color.blue | The border color of the box. |
border_width | series int | 1 | The border width in pixels. |
border_style | series string | line.style_solid | The border line style. |
extend | series string | extend.none | The extension mode: extend.none, extend.left, extend.right, or extend.both. |
xloc | series string | xloc.bar_index | The x-location type: xloc.bar_index or xloc.bar_time. |
bgcolor | series color | color.blue | The background color of the box. |
text | series string | "" | The text content of the box. |
text_size | series int | 0 | The text size in pixels. |
text_color | series color | color.black | The text color. |
text_halign | series string | text.align_right | The horizontal text alignment. |
text_valign | series string | text.align_center | The vertical text alignment. |
text_wrap | series string | text.wrap_none | The text wrapping mode. |
text_font_family | series string | font.family_default | The font family for the text. |
force_overlay | const bool | false | If true, the box is rendered on top. |
text_formatting | const text_format | text.format_none | The text formatting options. |
Returns: series box
Methods
copy
box.copy(series box id) → series boxCreates a copy of the specified box and returns its id.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to copy. |
Returns: series box
delete
box.delete(series box id)Deletes the specified box from the chart.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to delete. |
get_bottom
box.get_bottom(series box id) → series floatReturns the price value of the bottom border of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to get the bottom coordinate from. |
Returns: series float
get_left
box.get_left(series box id) → series intReturns the bar index or the UNIX time (depending on the last value used for 'xloc') of the left border of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to get the left coordinate from. |
Returns: series int
get_right
box.get_right(series box id) → series intReturns the bar index or the UNIX time (depending on the last value used for 'xloc') of the right border of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to get the right coordinate from. |
Returns: series int
get_top
box.get_top(series box id) → series floatReturns the price value of the top border of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to get the top coordinate from. |
Returns: series float
set_bgcolor
box.set_bgcolor(series box id, series color color)Sets the background color of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
color | series color | The new background color. |
set_border_color
box.set_border_color(series box id, series color color)Sets the border color of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
color | series color | The new border color. |
set_border_style
box.set_border_style(series box id, series string style)Sets the border style of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
style | series string | The new border line style. |
set_border_width
box.set_border_width(series box id, series int width)Sets the border width of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
width | series int | The new border width in pixels. |
set_bottom
box.set_bottom(series box id, series float bottom)Sets the bottom coordinate of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
bottom | series float | The new bottom coordinate (price). |
set_bottom_right_point
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
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
point | series chart.point | The chart.point object specifying the new bottom-right corner. |
set_extend
box.set_extend(series box id, series string extend)Sets extending type of the border of this box object.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
extend | series string | The extension mode: extend.none, extend.left, extend.right, or extend.both. |
set_left
box.set_left(series box id, series int left)Sets the left coordinate of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
left | series int | The new left coordinate (bar index or UNIX time). |
set_lefttop
box.set_lefttop(series box id, series int left, series float top)Sets the left and top coordinates of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
left | series int | The new left coordinate (bar index or UNIX time). | |
top | series float | The new top coordinate (price). |
set_right
box.set_right(series box id, series int right)Sets the right coordinate of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
right | series int | The new right coordinate (bar index or UNIX time). |
set_rightbottom
box.set_rightbottom(series box id, series int right, series float bottom)Sets the right and bottom coordinates of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
right | series int | The new right coordinate (bar index or UNIX time). | |
bottom | series float | The new bottom coordinate (price). |
set_text
box.set_text(series box id, series string text)Sets the text size of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
text | series string | The new text content. |
set_text_color
box.set_text_color(series box id, series color text_color)Sets the text color of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
text_color | series color | The new text color. |
set_text_font_family
box.set_text_font_family(series box id, series string font_family)Sets the font family of the box text.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
font_family | series string | The font family: font.family_default or font.family_monospace. |
set_text_formatting
box.set_text_formatting(series box id, const text_format text_formatting)Sets the text formatting of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
text_formatting | const text_format | The text formatting options. |
set_text_halign
box.set_text_halign(series box id, series string text_halign)Sets the horizontal alignment of the box text.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
text_halign | series string | The horizontal text alignment: text.align_left, text.align_center, or text.align_right. |
set_text_size
Sets the text size of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
text_size | series int | The new text size in pixels. |
set_text_valign
box.set_text_valign(series box id, series string text_valign)Sets the vertical alignment of the box text.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
text_valign | series string | The vertical text alignment: text.align_top, text.align_center, or text.align_bottom. |
set_text_wrap
box.set_text_wrap(series box id, series string text_wrap)Sets the text wrapping mode of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
text_wrap | series string | The text wrapping mode: text.wrap_none or text.wrap_auto. |
set_top
box.set_top(series box id, series float top)Sets the top coordinate of the box.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
top | series float | The new top coordinate (price). |
set_top_left_point
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
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
point | series chart.point | The chart.point object specifying the new top-left corner. |
set_xloc
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
| Name | Type | Default | Description |
|---|---|---|---|
id | series box | The box to modify. | |
left | series int | The new left coordinate (bar index or UNIX time). | |
right | series int | The new right coordinate (bar index or UNIX time). | |
xloc | series string | The x-location type: xloc.bar_index or xloc.bar_time. |