Sidechair

table.merge_cells()

Browse the reference

Fuses a rectangular block of cells into one cell that spans several columns, rows or both.

Try it in the editor

table.merge_cells(t, 0, 0, 2, 0) turns the top row of a three-column table into one title cell. The block runs from the start column and row to the end column and row, both included, so (0, 0, 1, 1) merges a two-by-two square.

The merged cell takes the content and style of its top-left cell. The order does not matter: merge before or after filling the cells, as long as the block lies inside the table.

Syntax

Pine Script
table.merge_cells(table_id: series table, start_column: series int, start_row: series int, end_column: series int, end_row: series int) -> void
table.merge_cells(start_column: series int, start_row: series int, end_column: series int, end_row: series int) -> void

Arguments

NameTypeDefaultDescription
table_idseries tablerequiredThe table whose cells are merged into one.
start_columnseries intrequiredColumn of the block's top-left cell, counting from 0 at the left.
start_rowseries intrequiredRow of the block's top-left cell, counting from 0 at the top.
end_columnseries intrequiredColumn of the block's bottom-right cell, counted from 0 and included in the merge.
end_rowseries intrequiredRow of the block's bottom-right cell, counted from 0 and included in the merge.

Returns

Nothing.

Remarks

Example

Pine ScriptTitle across the topOpen in editor
//@version=6
indicator("table.merge_cells: title row", overlay = true)
var t = table.new(position.top_right, 3, 2)
if barstate.isfirst
    table.merge_cells(t, 0, 0, 2, 0)
    table.cell(t, 0, 0, "Session stats", bgcolor = color.navy, text_color = color.white)
if barstate.islast
    table.cell(t, 0, 1, str.tostring(close))

See also

Runs on Sidechair