Sidechair

label.set_textalign()

Browse the reference

Sets how the lines of a multi-line label line up with each other: left, center or right.

Try it in the editor

The alignment applies to each line of the text against the others, so it only matters when the text has line breaks. A one-line label looks the same under all three values.

Right alignment suits stacked numbers of different lengths, because the last digits line up in a column.

Syntax

Pine Script
label.set_textalign(id: series label, textalign: series string) -> void
label.set_textalign(textalign: series string) -> void

Arguments

NameTypeDefaultDescription
idseries labelrequiredThe label whose multi-line text alignment changes. The words and shape are not touched.
textalignseries stringrequiredtext.align_left, text.align_center or text.align_right: how the lines of a multi-line label line up with each other.

Returns

Nothing.

Remarks

  • On Sidechair: the value is stored and returned unchanged, but every line is drawn centered, so text.align_left and text.align_right currently look like text.align_center.

Example

Pine ScriptRight-aligned OHLC stackOpen in editor
//@version=6
indicator("label.set_textalign: OHLC column", overlay = true)
var label l = label.new(bar_index, high, "")
label.set_xy(l, bar_index, high)
label.set_text(l, "O " + str.tostring(open, "#.##") + "\nH " + str.tostring(high, "#.##") + "\nL " + str.tostring(low, "#.##") + "\nC " + str.tostring(close, "#.##"))
label.set_textalign(l, text.align_right)

See also

Runs on Sidechair