Sidechair

table.clear()

Browse the reference

Empties every cell in a block of a table while the grid keeps its size, position and frame.

Try it in the editor

The block runs from start_column and start_row to end_column and end_row, both included. Leave the end out and only the start cell is cleared. The table itself stays on the chart with the same shape.

Clear before rebuilding a table whose layout changes, so text from the old layout does not linger in cells the new one leaves unused.

Syntax

Pine Script
table.clear(table_id: series table, start_column: series int, start_row: series int, end_column: series int (optional), end_row: series int (optional)) -> void
table.clear(start_column: series int, start_row: series int, end_column: series int (optional), end_row: series int (optional)) -> void

Arguments

NameTypeDefaultDescription
table_idseries tablerequiredThe table whose cells are emptied.
start_columnseries intrequiredColumn of the first cell to empty, counting from 0 at the left.
start_rowseries intrequiredRow of the first cell to empty, counting from 0 at the top.
end_columnseries intstart_columnLast column to empty, included. The default is start_column, which limits the clear to one column.
end_rowseries intstart_rowLast row to empty, included. The default is start_row, which limits the clear to one row.

Returns

Nothing.

Remarks

  • Clearing a cell drops its text and its own colors; it is the cell that is emptied, not the table's bgcolor, frame or border settings.

Example

Pine ScriptClear the body, keep the headerOpen in editor
//@version=6
indicator("table.clear: refresh body", overlay = true)
var t = table.new(position.top_left, 2, 4)
if barstate.islast
    table.clear(t, 0, 1, 1, 3)
    table.cell(t, 0, 1, "Close")
    table.cell(t, 1, 1, str.tostring(close))

See also

Runs on Sidechair