Home » Table Functions » Introduction to the table.cell_set_tooltip() Function in Pine Script

Introduction to the table.cell_set_tooltip() Function in Pine Script

Photo of author
Published on

In this article, we’ll delve into the syntax, arguments, and practical applications of table.cell_set_tooltip(), accompanied by an example to illustrate its usage in a Pine Script indicator.

Understanding the Syntax and Arguments


The syntax for the table.cell_set_tooltip() function is as follows:

table.cell_set_tooltip(table_id, column, row, tooltip) → void

This function does not return any value (void), but it performs an action on the table object by setting a tooltip for a specified cell.


  • table_id (series table): This is the identifier for the table object. It specifies which table the function will target for setting the tooltip.
  • column (series int): This argument defines the index of the column in which the cell is located. Column numbering starts at 0.
  • row (series int): Similar to column, this specifies the row index of the cell. Row numbering also starts at 0.
  • tooltip (series string): This is the text that will be displayed as a tooltip when the user hovers over the specified cell.

Example: Adding Tooltips to Table Cells

Let’s explore a practical example to see table.cell_set_tooltip() in action. We’ll create a simple table and add a tooltip to one of its cells.

indicator("TABLE example", overlay = false)
var table_id = table.new(position = position.top_center, rows = 1, columns = 2, bgcolor = color.yellow, border_width = 1)
table.cell(table_id, row = 0, column = 0, text = "Hover me!", text_color = color.blue)
table.cell_set_tooltip(table_id, row = 0, column = 0, tooltip = "Tooltip text here")


  1. Creating a Table: We start by creating a new table table_id using table.new(), specifying its position, number of rows and columns, background color, and border width.
  2. Adding Cell Content: Next, we use table.cell() to add text to the first cell of the table (row 0, column 0) with the text “Hover me!” in blue color.
  3. Setting a Tooltip: Finally, we apply table.cell_set_tooltip() to the same cell, setting a tooltip that will display “Tooltip text here” when the cell is hovered over.

Key Features and Takeaways

  • Enhanced User Experience: Tooltips can provide additional context or information, improving the user’s understanding and interaction with the table.
  • Customizable: You can set different tooltips for any cell, allowing for a high degree of customization.
  • Easy to Implement: Adding tooltips is straightforward and can significantly enhance the functionality of your custom tables in TradingView scripts.

This function is a simple yet powerful way to add interactive elements to your tables in Pine Script, making your indicators and strategies more informative and user-friendly.

Leave a Comment