Sidechair

table()

Browse the reference

table(x) gives na a table type, so a variable can be declared as a table before table.new() fills it.

Try it in the editor

table(na) is the typed na to start from when a variable will later hold a table, as in var t = table(na). A table that already exists passes through unchanged.

The same job is done by var table t = na, which reads more clearly in most scripts.

Syntax

Pine Script
table(x: series table) -> series table

Arguments

NameTypeDefaultDescription
xseries tablerequiredThe value to treat as a table. Pass na to get an empty, table-typed variable; a real table is returned as is.

Returns

series table: The argument, typed as a table. A table-typed na when na was passed.

Example

Pine ScriptTyped na until the first barOpen in editor
//@version=6
indicator("table cast: typed na", overlay = true)
var t = table(na)
plot(na(t) ? 1 : 0, "Table is na")

See also

Runs on Sidechair