Skip to main content
A table is a fixed grid of text cells pinned to a corner or edge of the chart, not to a price or bar. Use one for a summary: a few statistics, a legend, a status.

Create and fill

table.new(position, columns, rows, bgcolor, frame_color, frame_width, border_color, border_width, force_overlay) creates the table. position is position.top_left, top_center, top_right, middle_left, middle_center, middle_right, bottom_left, bottom_center or bottom_right. table.cell(table, column, row, text, width, height, textcolor, texthalign, textvalign, size, bgcolor, tooltip, ...) sets a cell; columns and rows count from 0. A cell outside the table is ignored. Create the table once, in a static variable, and fill it only on the last bar, where the values are final:
Calling table.cell again on the same cell replaces its content.

Change a table

  • Cells: table.cell_set_text, cell_set_bgcolor, cell_set_text_color, cell_set_text_size, cell_set_text_halign, cell_set_text_valign, cell_set_width, cell_set_height, cell_set_tooltip, each taking the table, the column and the row first.
  • Whole table: table.set_position, set_bgcolor, set_frame_color, set_frame_width, set_border_color, set_border_width.
  • table.merge_cells(table, start_column, start_row, end_column, end_row) joins a block; table.clear(...) empties a block of cells; table.delete(table) removes the table.
The functions work as methods too: t.cell(0, 0, "x").

Limits

There is room for one table per position: nine in all. A new table at a position that already has one deletes the old one, so a script that makes a table on every bar keeps only the last. The limit cannot be changed. Cell text is limited to 999 characters.