Writes one cell's text and style, replacing everything that cell held, including colors set earlier.
table.cell(t, 1, 2, "Volume") writes into the second column of the third row. A second call for the same cell starts that cell over, so any styling not repeated falls back to its default. Use table.cell_set_text() when only the words change.
width and height are percentages of the chart's width and height, and 0 sizes the cell to its text. text_halign, text_valign, text_size, text_formatting and text_font_family shape the text, bgcolor fills the cell, and tooltip adds hover text.
Syntax
table.cell(table_id: series table, column: series int, row: series int, text: series string (optional), width: series int/float (optional), height: series int/float (optional), text_color: series color (optional), text_halign: series string (optional), text_valign: series string (optional), text_size: series int/string (optional), bgcolor: series color (optional), tooltip: series string (optional), text_font_family: series string (optional), text_formatting: series text_format (optional)) -> void
table.cell(column: series int, row: series int, text: series string (optional), width: series int/float (optional), height: series int/float (optional), text_color: series color (optional), text_halign: series string (optional), text_valign: series string (optional), text_size: series int/string (optional), bgcolor: series color (optional), tooltip: series string (optional), text_font_family: series string (optional), text_formatting: series text_format (optional)) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| table_id | series table | required | The table that holds the cell being written. |
| column | series int | required | Column of the cell, counting from 0 at the left. It must be smaller than the table's column count. |
| row | series int | required | Row of the cell, counting from 0 at the top. It must be smaller than the table's row count. |
| text | series string | "" | Words shown in the cell. The default empty string leaves the cell blank. |
| width | series int/ | 0 | Cell width as a percent of the chart width. The default 0 sizes the cell to fit its text. |
| height | series int/ | 0 | Cell height as a percent of the chart height. The default 0 sizes the cell to fit its text. |
| text_color | series color | na | Color of the cell's text. Use color.new() for a faded, partly transparent text. |
| text_halign | series string | text. | Horizontal placement of the text: text.align_left, text.align_center (default) or text.align_right. |
| text_valign | series string | text. | Vertical placement of the text: text.align_top, text.align_center (default) or text.align_bottom. |
| text_size | series int/ | size. | Text size: size.auto, size.tiny, size.small, size.normal (default), size.large or size.huge. |
| bgcolor | series color | na | Fill of this one cell. na leaves it unfilled so the table's own bgcolor shows through. |
| tooltip | series string | "" | Pop-up text shown when the pointer rests on the cell. The default empty string shows none. |
| text_font_family | series string | font. | Typeface of the text: font.family_default, or font.family_monospace for equal-width characters. |
| text_formatting | series text_format | text. | text.format_none (default), text.format_bold or text.format_italic. Add the two with + for both. |
Returns
Nothing.
Remarks
- A column or row outside the size given to
table.new()stops the script with a runtime error.
Example
//@version=6
indicator("table.cell: label and value", overlay = true)
var t = table.new(position.bottom_right, 2, 2, bgcolor = color.new(color.gray, 75))
if barstate.islast
table.cell(t, 0, 0, "Volume", width = 7, text_halign = text.align_left)
table.cell(t, 1, 0, str.tostring(volume, format.volume), width = 7, text_halign = text.align_right, text_formatting = text.format_bold)
table.cell(t, 0, 1, "Range", text_halign = text.align_left)
table.cell(t, 1, 1, str.tostring(high - low, "#.##"), text_halign = text.align_right, tooltip = "High minus low of the bar")See also
Runs on Sidechair