Sidechair

table.set_position()

Browse the reference

Re-anchors an existing table to a different one of the nine screen positions without touching its cells.

Try it in the editor

The nine values are position.top_left, top_center, top_right, middle_left, middle_center, middle_right, bottom_left, bottom_center and bottom_right. Cells, colors and size stay as they were; only the anchor moves.

The position can change on any bar, so a table can follow a user setting or a condition. A table belongs to one slot at a time.

Syntax

Pine Script
table.set_position(table_id: series table, position: series string) -> void
table.set_position(position: series string) -> void

Arguments

NameTypeDefaultDescription
table_idseries tablerequiredThe table that moves to another screen position.
positionseries stringrequiredThe new screen slot: a position.* constant such as position.bottom_left or position.middle_center.

Returns

Nothing.

Example

Pine ScriptDock the table in a corner chosen in settingsOpen in editor
//@version=6
indicator("table.set_position: corner input", overlay = true)
corner = input.string("Top right", "Table corner", options = ["Top left", "Top right", "Bottom left", "Bottom right"])
pos = switch corner
    "Top left" => position.top_left
    "Top right" => position.top_right
    "Bottom left" => position.bottom_left
    => position.bottom_right
var t = table.new(position.top_right, 1, 1)
if barstate.islast
    table.cell(t, 0, 0, "Panel")
    table.set_position(t, pos)

See also

Runs on Sidechair