Make a dashboard on your chart (tables) · Pine Script EP 12 #shorts

A Pine Script table is a box pinned to the chart pane — not to a bar — so it stays in its corner while you scroll or zoom. table.new(position, columns, rows) creates it; table.cell(table, column, row, text) fills one cell, and columns and rows count from 0. str.tostring() turns a number into text for a cell. The manual’s advice: declare the table with var so it is created once (without var, table.new runs on every bar), and fill the cells only on the last bar with if barstate.islast — a table only ever shows its state on the last bar, so writing it on every bar is wasted work.

The code:
//@version=6
indicator(“Demo · dashboard”, overlay = true)
rsi = ta.rsi(close, 14)
var table t = table.new(position.top_right, 2, 2, bgcolor = color.new(color.black, 20))
if barstate.islast
table.cell(t, 0, 0, “RSI”, text_color = color.white)
table.cell(t, 1, 0, str.tostring(rsi, “#.0”), text_color = color.orange)
table.cell(t, 0, 1, “TF”, text_color = color.white)
table.cell(t, 1, 1, timeframe.period, text_color = color.orange)

Pine Script EP 12. Next: EP 13 — line.new (draw your own lines).

Educational example.

Your rules. Coded. · marketalgobot.com
https://marketalgobot.com

#pinescript #tradingview #coding #learntocode #marketalgobot