> ## Documentation Index
> Fetch the complete documentation index at: https://gocharting.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How to show a table of values

> Creating a table once, filling its cells on the last bar, and the limit of one table per position on the chart.

A table is a grid of text cells drawn in a corner of the chart. Create it once, keep its handle in a `static` variable, and fill the
cells on `barstate.islast`, so the work is done for the one bar the reader looks at and not for every bar of the history.

`table.new(position, columns, rows)` makes the grid and `table.cell(table, column, row, text)` sets a cell; columns and rows count from
0\. Cell text is a string, so convert numbers with `str.tostring`.

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Last bar summary", overlay=true)
static table info = table.new(position.top_right, 2, 3, border_width=1)
if barstate.islast {
    table.cell(info, 0, 0, "Close")
    table.cell(info, 1, 0, str.tostring(close))
    table.cell(info, 0, 1, "High")
    table.cell(info, 1, 1, str.tostring(high))
    table.cell(info, 0, 2, "Volume")
    table.cell(info, 1, 2, str.tostring(volume), bgcolor=color.new(color.blue, 0.2))
}
```

`table.cell` also takes `textcolor`, `bgcolor`, `size`, `width` and `height`. To change only the text of a cell later, use
`table.cell_set_text(table, column, row, text)`.

## Limits

* Position is one of the nine `position.*` constants (`position.top_left`, `position.middle_center`, `position.bottom_right`, ...).
* A chart holds one table per position. Creating a second table at the same position deletes the first, so a script has at most
  nine tables.
* Cell text is at most 999 characters; a longer string stops the script when it runs.

## The mistake to avoid

Calling `table.new` on every bar. Each call makes a new table that replaces the one at that position, so the table is rebuilt
on every bar. Create it once in a `static` variable, as above.
See [Tables](https://gocharting.com/docs/scripting/chart-output/tables.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.