Sidechair

table.cell_set_bgcolor()

Browse the reference

Sets the fill of a single cell, painting over the table's own background.

Try it in the editor

The cell fill takes priority over table.set_bgcolor(). Passing na removes the cell fill so the table background shows there again.

Heat-map tables come from calling it for each cell with a color computed from that cell's value.

Syntax

Pine Script
table.cell_set_bgcolor(table_id: series table, column: series int, row: series int, bgcolor: series color (optional)) -> void
table.cell_set_bgcolor(column: series int, row: series int, bgcolor: series color (optional)) -> void

Arguments

NameTypeDefaultDescription
table_idseries tablerequiredThe table that holds the cell whose fill changes.
columnseries intrequiredColumn of the cell whose fill changes, counting from 0 at the left.
rowseries intrequiredRow of the cell whose fill changes, counting from 0 at the top.
bgcolorseries colornaNew fill for this one cell. na removes it, so the table's own background shows again.

Returns

Nothing.

Example

Pine ScriptA row of RSI cells shaded by zoneOpen in editor
//@version=6
indicator("table.cell_set_bgcolor: RSI zones", overlay = true)
vals = array.from(ta.rsi(close, 7), ta.rsi(close, 14), ta.rsi(close, 28))
var t = table.new(position.top_right, 3, 1)
if barstate.islast
    for i = 0 to 2
        v = vals.get(i)
        table.cell(t, i, 0, str.tostring(v, "#"))
        table.cell_set_bgcolor(t, i, 0, v > 70 ? color.red : v < 30 ? color.green : color.gray)

See also

Runs on Sidechair