PINE LIBRARY
Updated XZ_Table_Primitives

Library "XZ_Table_Primitives"
Generic Pine table construction and cell-rendering primitives for XZ scripts. Contains no trading methodology or analytical authority.
resolvePosition(key)
Resolves a normalized position key to a Pine table position.
Parameters:
key (string): Position key: top_left, top_center, top_right, middle_left, middle_center, middle_right, bottom_left, bottom_center or bottom_right.
Returns: Pine position constant.
resolveTextSize(key)
Resolves a normalized text-size key to a Pine size constant.
Parameters:
key (string): Text-size key: tiny, small, normal, large or huge.
Returns: Pine size constant.
create(positionKey, columns, rows, backgroundColor, frameColor, frameWidth)
Creates a table using caller-supplied presentation values.
Parameters:
positionKey (string): Normalized table position key.
columns (int): Number of columns.
rows (int): Number of rows.
backgroundColor (color): Table background color.
frameColor (color): Table frame color.
frameWidth (int): Table frame width.
Returns: New table handle.
clearRegion(id, firstColumn, firstRow, lastColumn, lastRow)
Clears a rectangular region of an existing table.
Parameters:
id (table): Table handle.
firstColumn (int): First column index.
firstRow (int): First row index.
lastColumn (int): Last column index.
lastRow (int): Last row index.
Returns: True after clearing.
cell(id, column, row, cellText, textColor, backgroundColor, textSize, horizontalAlign, tooltipText)
Writes one fully specified table cell.
Parameters:
id (table): Table handle.
column (int): Column index.
row (int): Row index.
cellText (string): Cell text.
textColor (color): Text color.
backgroundColor (color): Cell background color.
textSize (string): Pine text size constant.
horizontalAlign (string): Pine text alignment constant.
tooltipText (string): Cell tooltip text.
Returns: True after writing.
twoColumnRow(id, row, labelText, valueText, labelColor, valueColor, backgroundColor, textSize, labelTooltip, valueTooltip)
Writes one two-column label/value row.
Parameters:
id (table): Table handle.
row (int): Row index.
labelText (string): Left-cell text.
valueText (string): Right-cell text.
labelColor (color): Left text color.
valueColor (color): Right text color.
backgroundColor (color): Shared cell background color.
textSize (string): Shared Pine text size constant.
labelTooltip (string): Left-cell tooltip.
valueTooltip (string): Right-cell tooltip.
Returns: True after writing both cells.
twoColumnHeader(id, row, leftText, rightText, leftColor, rightColor, backgroundColor, textSize, leftTooltip, rightTooltip)
Writes one two-column header/decoder row.
Parameters:
id (table): Table handle.
row (int): Row index.
leftText (string): Left-cell text.
rightText (string): Right-cell text.
leftColor (color): Left text color.
rightColor (color): Right text color.
backgroundColor (color): Shared background color.
textSize (string): Shared Pine text size constant.
leftTooltip (string): Left-cell tooltip.
rightTooltip (string): Right-cell tooltip.
Returns: True after writing both cells.
mergedSection(id, row, firstColumn, lastColumn, sectionText, textColor, backgroundColor, textSize, tooltipText)
Writes one merged full-width section row.
Parameters:
id (table): Table handle.
row (int): Row index.
firstColumn (int): First column to merge.
lastColumn (int): Last column to merge.
sectionText (string): Section text.
textColor (color): Text color.
backgroundColor (color): Cell background color.
textSize (string): Pine text size constant.
tooltipText (string): Cell tooltip.
Returns: True after writing and merging.
Generic Pine table construction and cell-rendering primitives for XZ scripts. Contains no trading methodology or analytical authority.
resolvePosition(key)
Resolves a normalized position key to a Pine table position.
Parameters:
key (string): Position key: top_left, top_center, top_right, middle_left, middle_center, middle_right, bottom_left, bottom_center or bottom_right.
Returns: Pine position constant.
resolveTextSize(key)
Resolves a normalized text-size key to a Pine size constant.
Parameters:
key (string): Text-size key: tiny, small, normal, large or huge.
Returns: Pine size constant.
create(positionKey, columns, rows, backgroundColor, frameColor, frameWidth)
Creates a table using caller-supplied presentation values.
Parameters:
positionKey (string): Normalized table position key.
columns (int): Number of columns.
rows (int): Number of rows.
backgroundColor (color): Table background color.
frameColor (color): Table frame color.
frameWidth (int): Table frame width.
Returns: New table handle.
clearRegion(id, firstColumn, firstRow, lastColumn, lastRow)
Clears a rectangular region of an existing table.
Parameters:
id (table): Table handle.
firstColumn (int): First column index.
firstRow (int): First row index.
lastColumn (int): Last column index.
lastRow (int): Last row index.
Returns: True after clearing.
cell(id, column, row, cellText, textColor, backgroundColor, textSize, horizontalAlign, tooltipText)
Writes one fully specified table cell.
Parameters:
id (table): Table handle.
column (int): Column index.
row (int): Row index.
cellText (string): Cell text.
textColor (color): Text color.
backgroundColor (color): Cell background color.
textSize (string): Pine text size constant.
horizontalAlign (string): Pine text alignment constant.
tooltipText (string): Cell tooltip text.
Returns: True after writing.
twoColumnRow(id, row, labelText, valueText, labelColor, valueColor, backgroundColor, textSize, labelTooltip, valueTooltip)
Writes one two-column label/value row.
Parameters:
id (table): Table handle.
row (int): Row index.
labelText (string): Left-cell text.
valueText (string): Right-cell text.
labelColor (color): Left text color.
valueColor (color): Right text color.
backgroundColor (color): Shared cell background color.
textSize (string): Shared Pine text size constant.
labelTooltip (string): Left-cell tooltip.
valueTooltip (string): Right-cell tooltip.
Returns: True after writing both cells.
twoColumnHeader(id, row, leftText, rightText, leftColor, rightColor, backgroundColor, textSize, leftTooltip, rightTooltip)
Writes one two-column header/decoder row.
Parameters:
id (table): Table handle.
row (int): Row index.
leftText (string): Left-cell text.
rightText (string): Right-cell text.
leftColor (color): Left text color.
rightColor (color): Right text color.
backgroundColor (color): Shared background color.
textSize (string): Shared Pine text size constant.
leftTooltip (string): Left-cell tooltip.
rightTooltip (string): Right-cell tooltip.
Returns: True after writing both cells.
mergedSection(id, row, firstColumn, lastColumn, sectionText, textColor, backgroundColor, textSize, tooltipText)
Writes one merged full-width section row.
Parameters:
id (table): Table handle.
row (int): Row index.
firstColumn (int): First column to merge.
lastColumn (int): Last column to merge.
sectionText (string): Section text.
textColor (color): Text color.
backgroundColor (color): Cell background color.
textSize (string): Pine text size constant.
tooltipText (string): Cell tooltip.
Returns: True after writing and merging.
Release Notes
v2Added:
createStyled(positionKey, columns, rows, backgroundColor, lineColor, showLines)
Creates a table with matching frame and border styling.
Parameters:
positionKey (string)
columns (int)
rows (int)
backgroundColor (color)
lineColor (color)
showLines (bool)
deleteTable(id)
Deletes a table when present.
Parameters:
id (table)
decoderRows(id, startRow, codes, terms, tooltips, accentColor, textColor, backgroundColor, textSize)
Renders code/term decoder rows with tooltip only on the code cell.
Parameters:
id (table)
startRow (int)
codes (array<string>)
terms (array<string>)
tooltips (array<string>)
accentColor (color)
textColor (color)
backgroundColor (color)
textSize (string)
Release Notes
v3Added:
decoderRowsAt(id, startColumn, startRow, codes, terms, tooltips, accentColor, textColor, backgroundColor, textSize)
Parameters:
id (table)
startColumn (int)
startRow (int)
codes (array<string>)
terms (array<string>)
tooltips (array<string>)
accentColor (color)
textColor (color)
backgroundColor (color)
textSize (string)
Updated:
resolvePosition(key)
Parameters:
key (simple string)
resolveTextSize(key)
Parameters:
key (simple string)
create(positionKey, columns, rows, backgroundColor, frameColor, frameWidth)
Parameters:
positionKey (simple string)
columns (int)
rows (int)
backgroundColor (color)
frameColor (color)
frameWidth (int)
createStyled(positionKey, columns, rows, backgroundColor, lineColor, showLines)
Parameters:
positionKey (simple string)
columns (int)
rows (int)
backgroundColor (color)
lineColor (color)
showLines (bool)
deleteTable(id)
Parameters:
id (table)
clearRegion(id, firstColumn, firstRow, lastColumn, lastRow)
Parameters:
id (table)
firstColumn (int)
firstRow (int)
lastColumn (int)
lastRow (int)
cell(id, column, row, cellText, textColor, backgroundColor, textSize, horizontalAlign, tooltipText)
Parameters:
id (table)
column (int)
row (int)
cellText (string)
textColor (color)
backgroundColor (color)
textSize (string)
horizontalAlign (string)
tooltipText (string)
twoColumnRow(id, row, labelText, valueText, labelColor, valueColor, backgroundColor, textSize, labelTooltip, valueTooltip)
Parameters:
id (table)
row (int)
labelText (string)
valueText (string)
labelColor (color)
valueColor (color)
backgroundColor (color)
textSize (string)
labelTooltip (string)
valueTooltip (string)
twoColumnHeader(id, row, leftText, rightText, leftColor, rightColor, backgroundColor, textSize, leftTooltip, rightTooltip)
Parameters:
id (table)
row (int)
leftText (string)
rightText (string)
leftColor (color)
rightColor (color)
backgroundColor (color)
textSize (string)
leftTooltip (string)
rightTooltip (string)
mergedSection(id, row, firstColumn, lastColumn, sectionText, textColor, backgroundColor, textSize, tooltipText)
Parameters:
id (table)
row (int)
firstColumn (int)
lastColumn (int)
sectionText (string)
textColor (color)
backgroundColor (color)
textSize (string)
tooltipText (string)
decoderRows(id, startRow, codes, terms, tooltips, accentColor, textColor, backgroundColor, textSize)
Parameters:
id (table)
startRow (int)
codes (array<string>)
terms (array<string>)
tooltips (array<string>)
accentColor (color)
textColor (color)
backgroundColor (color)
textSize (string)
Release Notes
v4Added:
twoColumnRowRight(id, row, labelText, valueText, labelColor, valueColor, backgroundColor, textSize, labelTooltip, valueTooltip)
Parameters:
id (table)
row (int)
labelText (string)
valueText (string)
labelColor (color)
valueColor (color)
backgroundColor (color)
textSize (string)
labelTooltip (string)
valueTooltip (string)
twoColumnHeaderRight(id, row, leftText, rightText, leftColor, rightColor, backgroundColor, textSize, leftTooltip, rightTooltip)
Parameters:
id (table)
row (int)
leftText (string)
rightText (string)
leftColor (color)
rightColor (color)
backgroundColor (color)
textSize (string)
leftTooltip (string)
rightTooltip (string)
twoColumnRowsRight(id, startRow, labels, values, labelTooltips, valueTooltips, accents, textColor, accentColor, backgroundColor, textSize)
Parameters:
id (table)
startRow (int)
labels (array<string>)
values (array<string>)
labelTooltips (array<string>)
valueTooltips (array<string>)
accents (array<bool>)
textColor (color)
accentColor (color)
backgroundColor (color)
textSize (string)
Release Notes
v5Added:
mergeRow(id, row, firstColumn, lastColumn)
Merges one horizontal row across the supplied columns without assigning semantic content.
Parameters:
id (table)
row (int)
firstColumn (int)
lastColumn (int)
horizontalCells(id, row, texts, textColors, tooltips, backgroundColor, textSize, firstCellLeft)
Renders a one-row horizontal strip from caller-supplied text/color/tooltip arrays. The first cell can be left-aligned while the remaining cells are right-aligned.
Parameters:
id (table)
row (int)
texts (array<string>)
textColors (array<color>)
tooltips (array<string>)
backgroundColor (color)
textSize (string)
firstCellLeft (bool)
Release Notes
v6Added:
twoColumnRowRightAt(id, startColumn, row, labelText, valueText, labelColor, valueColor, backgroundColor, textSize, labelTooltip, valueTooltip)
Renders the same generic two-column row at an arbitrary starting column. Useful for side-by-side panes without embedding consumer semantics in the library.
Parameters:
id (table)
startColumn (int)
row (int)
labelText (string)
valueText (string)
labelColor (color)
valueColor (color)
backgroundColor (color)
textSize (string)
labelTooltip (string)
valueTooltip (string)
Release Notes
v7Added:
newPackedGridLayout(logicalStarts, physicalRows, physicalColumns)
Creates a generic packed-grid mapping. Arrays are caller supplied and carry no semantic meaning.
Parameters:
logicalStarts (array<int>)
physicalRows (array<int>)
physicalColumns (array<int>)
packedGridRow(layout, logicalRow)
Parameters:
layout (PackedGridLayout)
logicalRow (int)
packedGridColumn(layout, logicalRow)
Parameters:
layout (PackedGridLayout)
logicalRow (int)
twoColumnRowRightPacked(id, packed, layout, logicalRow, labelText, valueText, labelColor, valueColor, backgroundColor, textSize, labelTooltip, valueTooltip)
Renders a generic logical two-column row either normally or through a caller-defined packed-grid mapping.
Parameters:
id (table)
packed (bool)
layout (PackedGridLayout)
logicalRow (int)
labelText (string)
valueText (string)
labelColor (color)
valueColor (color)
backgroundColor (color)
textSize (string)
labelTooltip (string)
valueTooltip (string)
packedSection(id, packed, layout, logicalRow, sectionText, textColor, backgroundColor, textSize, tooltipText)
Renders a caller-supplied section title in one logical pane row.
Parameters:
id (table)
packed (bool)
layout (PackedGridLayout)
logicalRow (int)
sectionText (string)
textColor (color)
backgroundColor (color)
textSize (string)
tooltipText (string)
mergePackedGrid(id, layout, topFullWidthRows, totalColumns)
Merges generic packed-grid section header rows plus an optional number of full-width top rows.
Parameters:
id (table)
layout (PackedGridLayout)
topFullWidthRows (int)
totalColumns (int)
PackedGridLayout
Generic mapping from logical section starts to physical table row/column starts.
Fields:
logical_starts (array<int>)
physical_rows (array<int>)
physical_columns (array<int>)
Release Notes
v8Added:
deconflictFour(enabled0, requested0, enabled1, requested1, enabled2, requested2, enabled3, requested3)
Resolves up to four independently enabled table positions without allowing two enabled tables to occupy the same Pine anchor. Earlier arguments have priority for their requested anchor; later conflicts fall forward to the next unused canonical anchor. Disabled tables do not claim positions.
Parameters:
enabled0 (bool)
requested0 (string)
enabled1 (bool)
requested1 (string)
enabled2 (bool)
requested2 (string)
enabled3 (bool)
requested3 (string)
twoColumnRowAt(id, startColumn, row, labelText, valueText, labelColor, valueColor, backgroundColor, textSize, labelTooltip, valueTooltip)
Renders a generic two-column row with both cells left-aligned at an arbitrary starting column.
Parameters:
id (table)
startColumn (int)
row (int)
labelText (string)
valueText (string)
labelColor (color)
valueColor (color)
backgroundColor (color)
textSize (string)
labelTooltip (string)
valueTooltip (string)
twoColumnRowPacked(id, packed, layout, logicalRow, labelText, valueText, labelColor, valueColor, backgroundColor, textSize, labelTooltip, valueTooltip)
Renders a generic logical two-column row either normally or through a caller-defined packed-grid mapping, with both cells left-aligned.
Parameters:
id (table)
packed (bool)
layout (PackedGridLayout)
logicalRow (int)
labelText (string)
valueText (string)
labelColor (color)
valueColor (color)
backgroundColor (color)
textSize (string)
labelTooltip (string)
valueTooltip (string)
Updated:
resolvePosition(key)
Parameters:
key (string)
create(positionKey, columns, rows, backgroundColor, frameColor, frameWidth)
Parameters:
positionKey (string)
columns (int)
rows (int)
backgroundColor (color)
frameColor (color)
frameWidth (int)
createStyled(positionKey, columns, rows, backgroundColor, lineColor, showLines)
Parameters:
positionKey (string)
columns (int)
rows (int)
backgroundColor (color)
lineColor (color)
showLines (bool)
Release Notes
v9Release Notes
v10Added:
twoColumnRows(id, startRow, labels, values, labelTooltips, valueTooltips, accents, textColor, accentColor, backgroundColor, textSize)
Renders caller-supplied two-column rows with both label and value cells left-aligned. Meaning, ordering and accent decisions remain caller-owned.
Parameters:
id (table)
startRow (int)
labels (array<string>)
values (array<string>)
labelTooltips (array<string>)
valueTooltips (array<string>)
accents (array<bool>)
textColor (color)
accentColor (color)
backgroundColor (color)
textSize (string)
horizontalCellsLeft(id, row, texts, textColors, tooltips, backgroundColor, textSize)
Renders a caller-supplied horizontal strip with every cell left-aligned.
Parameters:
id (table)
row (int)
texts (array<string>)
textColors (array<color>)
tooltips (array<string>)
backgroundColor (color)
textSize (string)
twoPaneTopicRows(id, startRow, leftTopics, leftBodies, rightTopics, rightBodies, topicColor, bodyColor, backgroundColor, textSize)
Renders two independent caller-supplied topic/body panes side by side. The library assigns no meaning to topics or body text.
Parameters:
id (table)
startRow (int)
leftTopics (array<string>)
leftBodies (array<string>)
rightTopics (array<string>)
rightBodies (array<string>)
topicColor (color)
bodyColor (color)
backgroundColor (color)
textSize (string)
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.