HUD Tables
Pine Script-style Stats Dashboard overlays designed to render analytics directly in the viewport corners.
ctx.table.new(position, columns, rows, bg, border_c, border_w)
Initializes a new rectangular table layout in one of the viewport corners.
const myTable = ctx.table.new(
ctx.position.bottom_right,
2,
4,
'rgba(26, 26, 46, 0.85)',
'rgba(57, 62, 70, 0.4)',
1
);
table.cell(col, row, text, options)
Exposes properties to populates cell values, backgrounds, and styling alignments. Options:
myTable.cell(0, 0, 'Metric', {
bgcolor: '#222831',
color: '#00adb5',
size: ctx.size.normal,
halign: 'center'
});
Available Cell Options:
color: Text color (e.g. hex, rgb, rgba).bgcolor: Cell background fill color.size: Text size constant (fromctx.size).halign: Horizontal text alignment:'left' | 'center' | 'right'.font: Custom font family string override.border_color: Border outline color for the cell.border_width: Thickness of cell borders.
table.set_merge(tableObj, startCol, startRow, endCol, endRow)
Merges a rectangular grid of cells (from startCol, startRow to endCol, endRow) into a single large cell. Perfect for table titles or wide data segments.
table.set_merge(myTable, 0, 0, 1, 0); // Merges columns 0 and 1 in row 0
Alignments & Constants
Exposed structures mapping layout constants on ctx:
ctx.position
Anchors HUD panels to screen bounds:
ctx.position.top_leftctx.position.top_rightctx.position.bottom_leftctx.position.bottom_right
ctx.size
Formats cell text sizes dynamically:
ctx.size.tinyctx.size.smallctx.size.normalctx.size.largectx.size.huge
Direct Pine HUDs & Strategy KPI Cards (v1.0.6)
In Direct Pine Mode (v1.0.6), persist a single HUD table with var and populate cells inside if barstate.islast. For backtest strategies, you can also push custom KPI cards and per-trade labels directly into the Strategy Tester UI via strategy.set_metric() and strategy.tag_trade().
var hud = table.new(position.top_right, 2, 2, bgcolor=color.new(color.black, 20))
if barstate.islast
table.cell(hud, 0, 0, "Symbol", text_color=color.gray)
table.cell(hud, 1, 0, syminfo.ticker, text_color=color.white)
table.cell(hud, 0, 1, "HLC3", text_color=color.gray)
table.cell(hud, 1, 1, str.tostring(hlc3, "#.##"), text_color=color.teal)