Sidechair

table.cell()

Browse the reference

Writes one cell's text and style, replacing everything that cell held, including colors set earlier.

Try it in the editor

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

Pine Script
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)) -> void

Arguments

NameTypeDefaultDescription
table_idseries tablerequiredThe table that holds the cell being written.
columnseries intrequiredColumn of the cell, counting from 0 at the left. It must be smaller than the table's column count.
rowseries intrequiredRow of the cell, counting from 0 at the top. It must be smaller than the table's row count.
textseries string""Words shown in the cell. The default empty string leaves the cell blank.
widthseries int/float0Cell width as a percent of the chart width. The default 0 sizes the cell to fit its text.
heightseries int/float0Cell height as a percent of the chart height. The default 0 sizes the cell to fit its text.
text_colorseries colornaColor of the cell's text. Use color.new() for a faded, partly transparent text.
text_halignseries stringtext.align_centerHorizontal placement of the text: text.align_left, text.align_center (default) or text.align_right.
text_valignseries stringtext.align_centerVertical placement of the text: text.align_top, text.align_center (default) or text.align_bottom.
text_sizeseries int/stringsize.normalText size: size.auto, size.tiny, size.small, size.normal (default), size.large or size.huge.
bgcolorseries colornaFill of this one cell. na leaves it unfilled so the table's own bgcolor shows through.
tooltipseries string""Pop-up text shown when the pointer rests on the cell. The default empty string shows none.
text_font_familyseries stringfont.family_defaultTypeface of the text: font.family_default, or font.family_monospace for equal-width characters.
text_formattingseries text_formattext.format_nonetext.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

Pine ScriptA label and a right-aligned bold valueOpen in editor
//@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