Replaces the text drawn inside a box; an empty string clears it.
The text sits at the centre of the box, in the text color and size set for it. Use it to name a zone or to show a live number such as the height of the range.
Rebuild the string on each bar with str.tostring() and a format such as "#.##" to keep a readout current without creating new boxes.
Syntax
box.set_text(id: series box, text: series string) -> void
box.set_text(text: series string) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series box | required | The box whose text changes. |
| text | series string | required | The new text. An empty string removes the text; build numbers into it with str.tostring(). |
Returns
Nothing.
Remarks
- On Sidechair: the text is drawn on one line and is not clipped to the box, so a long string spills past narrow edges. Passing na stores the word NaN, so pass an empty string to clear the text.
Example
//@version=6
indicator("box.set_text: height", overlay = true)
var box z = box.new(bar_index, high, bar_index + 1, low, bgcolor = color.new(color.blue, 88), text_color = color.white)
box.set_right(z, bar_index)
box.set_text(z, str.tostring(box.get_top(z) - box.get_bottom(z), "#.##"))See also
Runs on Sidechair