Skip to main content
ATK Pine Script®

table.* Functions Reference

Reference for table.new, table.cell, and ctx.table in ATK PyneScript V6 — native table widgets and managed dashboard tables.

table.* Overview#

SurfaceUse it whenRecommended stage
table.new(...)The table structure is static and can be declared once at import time.Module scope or render stage for simple widgets.
table.cell(...)You want to populate or refresh cell content on a managed table handle.Render stage when values depend on the current frame slice.
ctx.table.new(...)You want a runtime-created table derived from the current frame slice.build_visuals(...) only.

table.new()#

Creates a managed table widget at a fixed position. Declared at module scope for static tables.

# Parameters: position, columns, rows, key, title
dashboard = table.new("top_right", 2, 3, key="dashboard", title="Summary")
table.cell(dashboard, 0, 0, "Metric")
table.cell(dashboard, 1, 0, "Value")

Position Values#

ValueLocation
"top_left"Top-left corner
"top_center"Top-center
"top_right"Top-right corner
"middle_left"Middle-left
"middle_center"Center of chart
"middle_right"Middle-right
"bottom_left"Bottom-left corner
"bottom_center"Bottom-center
"bottom_right"Bottom-right corner

table.cell()#

Populates or updates a single cell in a managed table handle.

table.cell(
    handle,           # table handle returned by table.new()
    column,           # 0-indexed column number
    row,              # 0-indexed row number
    text,             # cell content string
    text_color=None,  # optional hex color string
    bgcolor=None,     # optional background hex color string
)

ctx.table.new()#

Creates a runtime table from inside build_visuals. Use when cell values depend on the current frame slice.

def build_visuals(frame, params=None, ctx=None):
    runtime_table = ctx.table.new("bottom_left", 2, 2, key="runtime_dashboard", title="Runtime")
    ctx.table.cell(runtime_table, 0, 0, "Bars")
    ctx.table.cell(runtime_table, 1, 0, str(len(frame)))
    return runtime_table

Full Native Table Pattern#

from source import indicator, table


indicator("Native Table Demo", overlay=True, max_bars_back=200)

dashboard = table.new("top_right", 2, 3, key="dashboard", title="Summary")
table.cell(dashboard, 0, 0, "Metric")
table.cell(dashboard, 1, 0, "Value")


def build_visuals(frame, params=None, ctx=None):
    runtime_table = ctx.table.new("bottom_left", 2, 2, key="runtime_dashboard", title="Runtime")
    ctx.table.cell(runtime_table, 0, 0, "Bars")
    ctx.table.cell(runtime_table, 1, 0, str(len(frame)))
    return runtime_table

ctx.atk.table() Bridge#

For richer ATK-native dashboard tables, use ctx.atk.table from inside build_visuals. Build the payload in the frame builder and render it here.

def build_indicator_frame(df, params=None):
    frame = df.copy().reset_index(drop=True)
    if not frame.empty:
        last = frame.iloc[-1]
        frame.attrs["visual_table_payload"] = {
            "position": "top-left",
            "title": "Signal Summary",
            "columns": 2,
            "rows": 3,
            "cells": [
                {"column": 0, "row": 0, "text": "Metric", "text_color": "#ffffff", "bgcolor": "#0f172a"},
                {"column": 1, "row": 0, "text": "Value",  "text_color": "#ffffff", "bgcolor": "#0f172a"},
                {"column": 0, "row": 1, "text": "Close"},
                {"column": 1, "row": 1, "text": f"{float(last['close']):.2f}", "text_color": "#00c853"},
            ],
        }
    return frame


def build_visuals(frame, params=None, ctx=None):
    payload = dict(frame.attrs.get("visual_table_payload") or {})
    if not payload:
        return None
    return ctx.atk.table(key="annotated_dashboard", **payload)

Use table.new / table.cell for simple static widgets declared at module scope. Reach for ctx.atk.table when the table needs dynamic columns, styled headers, or is part of a larger ATK bridge payload.

See also: