table

On-chart data tables — create, populate, and style tables to display information directly on your chart. Tables are useful for showing strategy statistics, price levels, or any other data you want to visualize alongside your price action.

Quick Example

  from pynecore.lib import script, table, position, color, close, bar_index

@script.indicator(title="Price Table", overlay=True)
def main():
    # Create a table at the top-left corner
    tbl: table.Table = table.new(
        position.top_left,
        columns=2,
        rows=3,
        bgcolor=color.gray,
        border_width=1
    )
    
    # Add header row
    table.cell(tbl, 0, 0, "Metric", text_color=color.white)
    table.cell(tbl, 1, 0, "Value", text_color=color.white)
    
    # Add data rows
    table.cell(tbl, 0, 1, "Close", text_color=color.white)
    table.cell(tbl, 1, 1, str(close), text_color=color.white)
    
    table.cell(tbl, 0, 2, "Bar", text_color=color.white)
    table.cell(tbl, 1, 2, str(bar_index), text_color=color.white)
  

Table Creation and Deletion

table.new()

Creates a new table on the chart.

ParameterTypeDescriptionDefault
positionposition.PositionWhere to place the table: position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right(required)
columnsintNumber of columns(required)
rowsintNumber of rows(required)
bgcolorcolor.ColorBackground color of the entire tableNone
frame_colorcolor.ColorColor of the outer frameNone
frame_widthintWidth of the outer frame in pixels0
border_colorcolor.ColorColor of cell borders (excluding outer frame)None
border_widthintWidth of cell borders in pixels0
force_overlayboolIf True, display on main chart even if indicator is in a separate paneFalse

Returns: table.Table — a table object to pass to other table.*() functions

Example:

  tbl: table.Table = table.new(position.top_left, 3, 4)
  

table.delete()

Deletes a table.

ParameterTypeDescription
table_idtable.TableThe table to delete

Returns: None

Table Styling

table.set_position()

Changes the position of a table on the chart.

ParameterTypeDescription
table_idtable.TableThe table to modify
positionposition.PositionNew position

Returns: None

table.set_bgcolor()

Sets the background color of the entire table.

ParameterTypeDescription
table_idtable.TableThe table to modify
bgcolorcolor.ColorBackground color

Returns: None

table.set_frame_color()

Sets the color of the table’s outer frame.

ParameterTypeDescription
table_idtable.TableThe table to modify
frame_colorcolor.ColorFrame color

Returns: None

table.set_frame_width()

Sets the width of the table’s outer frame.

ParameterTypeDescription
table_idtable.TableThe table to modify
frame_widthintFrame width in pixels

Returns: None

table.set_border_color()

Sets the color of cell borders (excluding the outer frame).

ParameterTypeDescription
table_idtable.TableThe table to modify
border_colorcolor.ColorBorder color

Returns: None

table.set_border_width()

Sets the width of cell borders (excluding the outer frame).

ParameterTypeDescription
table_idtable.TableThe table to modify
border_widthintBorder width in pixels

Returns: None

Cell Operations

table.cell()

Creates or updates a cell with text and formatting.

ParameterTypeDescriptionDefault
table_idtable.TableThe table containing the cell(required)
columnintColumn index (0-based)(required)
rowintRow index (0-based)(required)
textstrCell text content""
widthint | floatCell width as percentage of visual space (0 = auto)0
heightint | floatCell height as percentage of visual space (0 = auto)0
text_colorcolor.ColorText colorcolor.black
text_haligntext.AlignHorizontal alignment: text.align_left, text.align_center, text.align_righttext.align_center
text_valigntext.AlignVertical alignment: text.align_top, text.align_center, text.align_bottomtext.align_center
text_sizeint | strText size: positive integer or size.tiny, size.small, size.normal, size.large, size.hugesize.normal
bgcolorcolor.ColorBackground colorNone
tooltipstrTooltip text on hover""
text_font_familyfont.FontFamilyFont: font.family_default, font.family_monospacefont.family_default
text_formattingtext.FormatFormatting: text.format_none, text.format_bold, text.format_italic, text.format_strikeouttext.format_none

Returns: None

Example:

  table.cell(tbl, 0, 0, "Price", text_color=color.white, bgcolor=color.blue)
  

table.cell_set_text()

Updates the text in a cell.

ParameterTypeDescription
table_idtable.TableThe table containing the cell
columnintColumn index
rowintRow index
textstrNew text content

Returns: None

Example:

  table.cell_set_text(tbl, 1, 1, str(close))
  

table.cell_set_bgcolor()

Sets the background color of a cell.

ParameterTypeDescription
table_idtable.TableThe table containing the cell
columnintColumn index
rowintRow index
bgcolorcolor.ColorBackground color

Returns: None

table.cell_set_text_color()

Sets the text color of a cell.

ParameterTypeDescription
table_idtable.TableThe table containing the cell
columnintColumn index
rowintRow index
text_colorcolor.ColorText color

Returns: None

table.cell_set_text_size()

Sets the text size of a cell.

ParameterTypeDescription
table_idtable.TableThe table containing the cell
columnintColumn index
rowintRow index
text_sizeint | strText size (integer or size constant)

Returns: None

table.cell_set_text_halign()

Sets the horizontal alignment of a cell’s text.

ParameterTypeDescription
table_idtable.TableThe table containing the cell
columnintColumn index
rowintRow index
text_haligntext.AlignAlignment: text.align_left, text.align_center, text.align_right

Returns: None

table.cell_set_text_valign()

Sets the vertical alignment of a cell’s text.

ParameterTypeDescription
table_idtable.TableThe table containing the cell
columnintColumn index
rowintRow index
text_valigntext.AlignAlignment: text.align_top, text.align_center, text.align_bottom

Returns: None

table.cell_set_width()

Sets the width of a cell.

ParameterTypeDescription
table_idtable.TableThe table containing the cell
columnintColumn index
rowintRow index
widthint | floatWidth as percentage (0 = auto)

Returns: None

table.cell_set_height()

Sets the height of a cell.

ParameterTypeDescription
table_idtable.TableThe table containing the cell
columnintColumn index
rowintRow index
heightint | floatHeight as percentage (0 = auto)

Returns: None

table.cell_set_tooltip()

Sets a tooltip that appears when hovering over a cell.

ParameterTypeDescription
table_idtable.TableThe table containing the cell
columnintColumn index
rowintRow index
tooltipstrTooltip text

Returns: None

table.cell_set_text_font_family()

Sets the font family of a cell’s text.

ParameterTypeDescription
table_idtable.TableThe table containing the cell
columnintColumn index
rowintRow index
text_font_familyfont.FontFamilyFont: font.family_default or font.family_monospace

Returns: None

table.cell_set_text_formatting()

Applies text formatting (bold, italic, strikethrough) to a cell.

ParameterTypeDescription
table_idtable.TableThe table containing the cell
columnintColumn index
rowintRow index
text_formattingtext.FormatFormat: text.format_none, text.format_bold, text.format_italic, text.format_strikeout

Returns: None

Table Utilities

table.clear()

Removes cells from a rectangular range within a table.

ParameterTypeDescription
table_idtable.TableThe table to modify
start_columnintStarting column index
start_rowintStarting row index
end_columnintEnding column index (defaults to start_column)
end_rowintEnding row index (defaults to start_row)

Returns: None

Example:

  table.clear(tbl, 0, 1, 1, 2)  # Clear cells from (0,1) to (1,2)
  

table.merge_cells()

Merges a rectangular range of cells into a single cell.

ParameterTypeDescription
table_idtable.TableThe table to modify
start_columnintStarting column index
start_rowintStarting row index
end_columnintEnding column index
end_rowintEnding row index

Returns: None

Example:

  table.merge_cells(tbl, 0, 0, 1, 0)  # Merge top two cells
  

Module Properties

table.all

Returns an array of all tables currently drawn by the script.

Type: list[table.Table]

Example:

  all_tables: list[table.Table] = table.all
  

Compatibility Notes

All functions in the table namespace are fully supported in PyneCore. The namespace provides complete table creation and manipulation capabilities matching TradingView’s Pine Script v6 table API.