Pine Script provides a rich set of functions allowing users to customize tables for displaying data on charts. One such function is table.cell_set_height()
, which adjusts the height of a specific cell within a table. This tutorial will explore the syntax, arguments, and practical applications of this function.
Syntax
The table.cell_set_height()
function is designed to modify the height of a cell within a table. Its syntax is as follows:
table.cell_set_height(table_id, column, row, height) → void
This function does not return any value (hence, void
), but it directly affects the table’s appearance on the chart.
Arguments
table_id
(series table
): This is the identifier for the table object you want to modify. It links the function call to a specific table created earlier in your script.column
(series int
): Specifies the column index of the cell whose height you wish to set. Column indexing starts at 0, meaning the first column is referenced as 0.row
(series int
): Indicates the row index of the cell. Similar to columns, row indexing also starts at 0.height
(series int/float
): Determines the new height of the cell as a percentage of the chart window. Setting this argument to 0 will make the cell height auto-adjust to fit the text inside.
Example
Imagine we have a table designed to display trading signals, and we want to adjust the height of a specific cell to emphasize its content.
First, let’s create a table and then modify the height of a cell:
//@version=5 indicator("My Table Example", overlay=true) // Creating a table myTable = table.new(position.top_right, 3, 2) // Populating the table with some data table.cell(myTable, 0, 0, "Signal") table.cell(myTable, 1, 0, "Buy") table.cell(myTable, 0, 1, "Price") table.cell(myTable, 1, 1, tostring(close)) // Adjusting the height of the 'Price' cell table.cell_set_height(myTable, 0, 1, 20) plot(close)

Walkthrough of Code
//@version=5
: This indicates the version of Pine Script being used, which is version 5 in this case.indicator("My Table Example", overlay=true)
: This line declares the script as an indicator with the title “My Table Example” and sets the overlay parameter to true, meaning it will be plotted on the main chart.myTable = table.new(position.top_right, 3, 2)
: This line creates a new table with 3 rows and 2 columns positioned at the top-right corner of the chart.table.cell(myTable, 0, 0, "Signal")
: This line sets the content of the cell in the first row and first column of the table to “Signal”.table.cell(myTable, 1, 0, "Buy")
: This line sets the content of the cell in the second row and first column of the table to “Buy”.table.cell(myTable, 0, 1, "Price")
: This line sets the content of the cell in the first row and second column of the table to “Price”.table.cell(myTable, 1, 1, tostring(close))
: This line sets the content of the cell in the second row and second column of the table to the string representation of the close price.table.cell_set_height(myTable, 0, 1, 20)
: This line adjusts the height of the cell in the first row and second column of the table to 20 pixels.plot(close)
: This line plots the closing price on the chart.
Key Features and Takeaways
- Function Usability: The
table.cell_set_height()
function is crucial for customizing the visual representation of tables in Pine Script, offering flexibility in displaying data. - Syntax and Application: Understanding the function’s arguments is key to accurately targeting and adjusting cell heights within your tables.
- Practical Use Case: This function is particularly useful in scenarios where certain data points need emphasis or better visibility within a table.
By mastering the table.cell_set_height()
function, you can enhance the readability and visual appeal of your tables in Pine Script, making your trading indicators and strategies more informative and user-friendly.