Sidechair

table.cell_set_text_halign()

Browse the reference

Places a cell's text against its left edge, center or right edge.

Try it in the editor

text.align_left, text.align_center and text.align_right position the text inside the cell. The choice only shows when the cell is wider than its text, for instance after setting a width.

Right-align a column of numbers so the digits line up under each other.

Syntax

Pine Script
table.cell_set_text_halign(table_id: series table, column: series int, row: series int, text_halign: series string (optional)) -> void
table.cell_set_text_halign(column: series int, row: series int, text_halign: series string (optional)) -> void

Arguments

NameTypeDefaultDescription
table_idseries tablerequiredThe table that holds the cell whose text is aligned.
columnseries intrequiredColumn of the cell whose text is aligned, counting from 0 at the left.
rowseries intrequiredRow of the cell whose text is aligned, counting from 0 at the top.
text_halignseries stringtext.align_centerHorizontal placement: text.align_left, text.align_center (default) or text.align_right.

Returns

Nothing.

Example

Pine ScriptRight-aligned numberOpen in editor
//@version=6
indicator("table.cell_set_text_halign: right", overlay = true)
var t = table.new(position.top_right, 1, 1)
if barstate.islast
    table.cell(t, 0, 0, str.tostring(close, "#.##"), width = 10)
    table.cell_set_text_halign(t, 0, 0, text.align_right)

See also

Runs on Sidechair