Skip to content
Algo Trade Analytics Docs

table.merge_cells() - Pine Script Function

The function merges a sequence of cells in the table into one cell. The cells are merged in a rectangle shape where the start_column and start_row specify the top-left corner, and end_column and end_row specify the bottom-right corner.

table.merge_cells(table_id, start_column, start_row, end_column, end_row) → void
NameTypeDescription
table_idseries tableA table object.
  • This function will merge cells, even if their properties are not yet defined with table.cell.
//@version=6
indicator("table.merge_cells example")
SMA50 = ta.sma(close, 50)
SMA100 = ta.sma(close, 100)
SMA200 = ta.sma(close, 200)
if barstate.islast maTable =
table.new(position.bottom_right, 3, 3, bgcolor = color.gray, border_width = 1, border_color = color.black) // Header table.cell(maTable, 0, 0, text = "SMA Table")
table.merge_cells(maTable, 0, 0, 2, 0) // Cell Titles table.cell(maTable, 0, 1, text = "SMA 50")
table.cell(maTable, 1, 1, text = "SMA 100")
table.cell(maTable, 2, 1, text = "SMA 200") // Values table.cell(maTable, 0, 2, bgcolor = color.white, text = str.tostring(SMA50))
table.cell(maTable, 1, 2, bgcolor = color.white, text = str.tostring(SMA100))
table.cell(maTable, 2, 2, bgcolor = color.white, text = str.tostring(SMA200))