Sidechair

box.set_text_valign()

Browse the reference

Sets where text sits along a box's height: under the top border, in the middle or above the bottom border.

Try it in the editor

text.align_top places the text under the upper border, text.align_bottom above the lower one, and text.align_center in the middle. The effect shows when the box is taller than its text.

Together with the horizontal setting it pins the text to any of nine positions inside the box.

Syntax

Pine Script
box.set_text_valign(id: series box, text_valign: series string) -> void
box.set_text_valign(text_valign: series string) -> void

Arguments

NameTypeDefaultDescription
idseries boxrequiredThe box whose vertical text position changes.
text_valignseries stringrequiredtext.align_top, text.align_center (default) or text.align_bottom. It has an effect only when the box is taller than its text.

Returns

Nothing.

Remarks

  • On Sidechair: vertical alignment is not applied yet, so a call reports a warning and the text stays in the middle.

Example

Pine ScriptCaption near the floor of a demand zoneOpen in editor
//@version=6
indicator("box.set_text_valign: caption at the floor", overlay = true)
if barstate.islast
    z = box.new(bar_index - 30, ta.highest(high, 30), bar_index, ta.lowest(low, 30), bgcolor = color.new(color.green, 88), text = "Demand", text_color = color.green)
    box.set_text_valign(z, text.align_bottom)

See also

Not on Sidechair yet