Empties every cell in a block of a table while the grid keeps its size, position and frame.
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
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)) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| table_id | series table | required | The table whose cells are emptied. |
| start_column | series int | required | Column of the first cell to empty, counting from 0 at the left. |
| start_row | series int | required | Row of the first cell to empty, counting from 0 at the top. |
| end_column | series int | start_column | Last column to empty, included. The default is start_column, which limits the clear to one column. |
| end_row | series int | start_row | Last 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
//@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