Skip to content

table ​

How do you show a few values in a fixed place on the screen? Make a table once, with var, at one of nine positions in the pane, then write its cells with table.cell. A table doesn't sit on bars or prices, so it stays put while the chart scrolls. Filling it on the last bar alone is enough, since only the last bar's table shows.

pine
//@version=6
indicator("Close in a table", overlay = true)
var table t = table.new(position.top_right, 2, 1, border_width = 1)
if barstate.isfirst
    table.cell(t, 0, 0, "Close", bgcolor = color.gray)
if barstate.islast
    // table.cell on 0, 0 again would reset its grey: change the text alone.
    table.cell_set_text(t, 0, 0, "Last close")
    txt = str.tostring(close, format.mintick)
    table.cell(t, 1, 0, txt, bgcolor = color.blue, text_color = color.white)

A table made at a position where a live table already sits replaces it, as table.delete would. A deleted table has no cells, and writes to it do nothing. Tables let the pointer through to the chart, except for showing a cell's tooltip.

table.cell sets the whole cell

Each table.cell call sets every option of its cell: an option it leaves out goes back to its default, even if an earlier call set it. Only a merge stays. To change one option, use the table.cell_set_* function for it.

table.new ​

pine
table.new(position, columns, rows, bgcolor, frame_color, frame_width, border_color, border_width, force_overlay) → series table

Makes a table of columns by rows empty cells at a position in the pane, and returns its handle.

ParameterDefaultDescription
position
series string
One of position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center and position.bottom_right.
columns
series int
How many columns, at least 1.
rows
series int
How many rows, at least 1.
bgcolor
series color
The table's fill behind its cells. Left out, none.
frame_color
series color
The colour of the line round the table. Left out, none.
frame_width
series int
0That line's width in pixels.
border_color
series color
The colour of the lines between cells. Left out, none.
border_width
series int
0Those lines' width in pixels.
force_overlay
const bool
falsetrue draws on the price pane even from a script with a pane of its own.

table.cell ​

pine
table.cell(table_id, column, row, text, width, height, text_color, text_halign, text_valign, text_size, bgcolor, tooltip, text_font_family, text_formatting) → void

Also a method: table_id.cell(column, row, text, width, height, text_color, text_halign, text_valign, text_size, bgcolor, tooltip, text_font_family, text_formatting).

Sets a cell's text and every one of its options.

Left out, a cell's text is "", its text colour color.black, its text centred both ways at size.auto, which draws as size.normal, with no fill, no tooltip, and its width and height fitted to its text. A cell outside the table does nothing.

Cells draw at TradingView's text sizes in pixels, size.tiny at 8, whatever the rest of the page uses. text_formatting changes nothing here yet.

ParameterDefaultDescription
table_id
series table
The table.
column
series int
The cell's column, from 0.
row
series int
The cell's row, from 0.
text
series string
""The words. \n starts a new line.
width
series int/float
0The cell's width as a percent of the pane's width. 0 fits it to its text.
height
series int/float
0The cell's height as a percent of the pane's height. 0 fits it to its text.
text_color
series color
color.blackThe text's colour.
text_halign
series string
text.align_centertext.align_left, text.align_center or text.align_right.
text_valign
series string
text.align_centertext.align_top, text.align_center or text.align_bottom.
text_size
series string
size.autosize.tiny, size.small, size.normal, size.large, size.huge or size.auto.
bgcolor
series color
naThe cell's fill.
tooltip
series string
""Words shown while the pointer is over the cell.
text_font_family
series string
font.family_defaultfont.family_default or font.family_monospace.
text_formattingNo effect here
const string
text.format_noneBold or italic text on TradingView. It changes nothing here yet.

table.cell_set_* ​

Each changes one option of one cell and leaves the cell's others as they are, where table.cell sets them all. A cell outside the table, or a deleted table, does nothing.

Each gives a void.

NameTakesWhat it means
table.cell_set_bgcolortable_id: series table, column: series int, row: series int, bgcolor: series colorSets the cell's fill.
table.cell_set_heighttable_id: series table, column: series int, row: series int, height: series intSets the cell's height.
table.cell_set_texttable_id: series table, column: series int, row: series int, text: series stringReplaces the cell's text.
table.cell_set_text_colortable_id: series table, column: series int, row: series int, text_color: series colorSets the text's colour.
table.cell_set_text_font_familytable_id: series table, column: series int, row: series int, text_font_family: series stringSets the text's font.
table.cell_set_text_formattingNo effect heretable_id: series table, column: series int, row: series int, text_formatting: const stringSets the text to bold or italic on TradingView. It changes nothing here yet.
table.cell_set_text_haligntable_id: series table, column: series int, row: series int, text_halign: series stringSets the text's place across the cell.
table.cell_set_text_sizetable_id: series table, column: series int, row: series int, text_size: series stringSets the text's size.
table.cell_set_text_valigntable_id: series table, column: series int, row: series int, text_valign: series stringSets the text's place up and down the cell.
table.cell_set_tooltiptable_id: series table, column: series int, row: series int, tooltip: series stringSets the words shown while the pointer is over the cell.
table.cell_set_widthtable_id: series table, column: series int, row: series int, width: series intSets the cell's width.
ParameterDescription
table_id
series table
The table.
column
series int
The cell's column, from 0.
row
series int
The cell's row, from 0.
bgcolor
series color
The colour.
height
series int
A percent of the pane's height. 0 fits it to its text.
text
series string
The words. \n starts a new line.
text_color
series color
The colour.
text_font_family
series string
font.family_default or font.family_monospace.
text_formatting
const string
text.format_none, text.format_bold, text.format_italic, or both added together.
text_halign
series string
text.align_left, text.align_center or text.align_right.
text_size
series string
size.tiny, size.small, size.normal, size.large, size.huge or size.auto.
text_valign
series string
text.align_top, text.align_center or text.align_bottom.
tooltip
series string
The words.
width
series int
A percent of the pane's width. 0 fits it to its text.

table.merge_cells ​

pine
table.merge_cells(table_id, start_column, start_row, end_column, end_row) → void

Also a method: table_id.merge_cells(start_column, start_row, end_column, end_row).

Merges a rectangle of cells into its top-left cell, which then spans them all and shows its own text. A later table.cell on that cell keeps the merge.

ParameterDescription
table_id
series table
The table.
start_column
series int
The rectangle's first column.
start_row
series int
The rectangle's first row.
end_column
series int
Its last column.
end_row
series int
Its last row.

table.clear ​

pine
table.clear(table_id, start_column, start_row, end_column, end_row) → void

Also a method: table_id.clear(start_column, start_row, end_column, end_row).

Empties cells' text and fill.

It clears the whole table here

This engine empties the text and fill of every cell in the table, whatever range you give, and leaves the cells' other options. TradingView clears only the cells in the range, and the whole of each. To clear part of a table, write "" into those cells with table.cell.

ParameterDescription
table_id
series table
The table.
start_column
series int
The range's first column.
start_row
series int
The range's first row.
end_column
series int
Its last column.
end_row
series int
Its last row.

table.delete ​

pine
table.delete(table_id) → void

Also a method: table_id.delete().

Takes the table off the chart. Its cells go with it, and writes to it do nothing.

ParameterDescription
table_id
series table
The table.

table.all ​

pine
array<table> table.all

An array of every table the script has on the chart, oldest first. A deleted or replaced table isn't in it.

table.set_position ​

pine
table.set_position(table_id, position) → void

Also a method: table_id.set_position(position).

Moves the table to another of the nine positions.

ParameterDescription
table_id
series table
The table.
position
series string
A position.* value, as in table.new.

table.set_bgcolor ​

pine
table.set_bgcolor(table_id, bgcolor) → void

Also a method: table_id.set_bgcolor(bgcolor).

Sets the table's fill behind its cells.

ParameterDescription
table_id
series table
The table.
bgcolor
series color
The colour.

table.set_frame_color ​

pine
table.set_frame_color(table_id, frame_color) → void

Also a method: table_id.set_frame_color(frame_color).

Sets the colour of the line round the table.

ParameterDescription
table_id
series table
The table.
frame_color
series color
The colour.

table.set_frame_width ​

pine
table.set_frame_width(table_id, frame_width) → void

Also a method: table_id.set_frame_width(frame_width).

Sets the width of the line round the table.

ParameterDescription
table_id
series table
The table.
frame_width
series int
The width in pixels.

table.set_border_color ​

pine
table.set_border_color(table_id, border_color) → void

Also a method: table_id.set_border_color(border_color).

Sets the colour of the lines between cells.

ParameterDescription
table_id
series table
The table.
border_color
series color
The colour.

table.set_border_width ​

pine
table.set_border_width(table_id, border_width) → void

Also a method: table_id.set_border_width(border_width).

Sets the width of the lines between cells.

ParameterDescription
table_id
series table
The table.
border_width
series int
The width in pixels.

See also ​

AmenoScript is compatible with Pine Script v6. Pine Script is a trademark of TradingView, Inc., which has no part in AmenoScript.