Skip to content
TradequixDocsOpen the terminal
OverviewStart here, search, progress
  • Introduction
  • Quickstart
  • How a script runs
  • Types and qualifiers
  • Operators, conditionals and loops
  • Functions and methods
  • Objects and enums
  • Arrays, matrices and maps
  • Strings and colours
  • Time and sessions
  • Bar states
  • Plotting
  • Inputs
  • Technical analysis
  • Drawings and tables
  • Multiple timeframes
  • Strategies
  • Alerts in scripts
  • Repainting
  • The Pine editor
  • Indicator settings
  • Coming from TradingView
  • The data
  • Publish and sell
  • Catalogue and community
  • Your dashboard and earnings
  • Errors and debugging
  • Limits
  • Coverage
  • Built-in catalogue
  • Cookbook
  • Write Pine with AI
  • FAQ
  • Glossary
  • Cheat sheet
  • Function reference
  • Will it run here?
  • Error index

Write

Drawings and tables

Labels, lines, boxes, polylines and tables: objects a script places at exact coordinates, and how they behave on Tradequix.

View as MarkdownOpen in ClaudeOpen in ChatGPT

Plots draw one value per bar. Drawings are objects you place yourself: a label at a price, a line between two points, a box around a range, a table pinned to a corner. Each is created with *.new(...) and can be changed later through the id it returns.

Labels and lines on the last bar#

A common pattern is to draw only once, on the last bar, so the object does not repeat on every bar of history.

RunnableLast price label
1//@version=62indicator("Last price label", overlay = true)3hi = ta.highest(high, 50)4lo = ta.lowest(low, 50)5if barstate.islast6 line.new(bar_index - 50, hi, bar_index, hi, color = color.red, width = 2)7 line.new(bar_index - 50, lo, bar_index, lo, color = color.teal, width = 2)8 label.new(bar_index, hi, "50-bar high " + str.tostring(hi, format.mintick), style = label.style_label_down, color = color.red, textcolor = color.white)9 label.new(bar_index, lo, "50-bar low " + str.tostring(lo, format.mintick), style = label.style_label_up, color = color.teal, textcolor = color.white)

bar_index counts bars from 0, so bar_index - 50 is fifty bars back.

Keeping one object up to date#

To keep a single object moving rather than creating a new one every bar, store its id in a var and update it:

pine
1//@version=62indicator("One moving label", overlay = true)3var label tag = label.new(na, na, "")4label.set_xy(tag, bar_index, close)5label.set_text(tag, str.tostring(close, format.mintick))

To remove objects, call label.delete(id), line.delete(id) and so on. Only objects that still exist at the end of the run are drawn.

Boxes#

RunnableRange box
1//@version=62indicator("Range box", overlay = true)3len = input.int(30, "Bars", minval = 5)4if barstate.islast5 top = ta.highest(high, len)6 bottom = ta.lowest(low, len)7 box.new(bar_index - len + 1, top, bar_index, bottom, border_color = color.new(#8b7cff, 0), bgcolor = color.new(#8b7cff, 85))

Tables#

A table is a grid pinned to a corner of the chart or pane: good for a dashboard of current values.

RunnableDashboard
1//@version=62indicator("Dashboard", overlay = true)3r = ta.rsi(close, 14)4a = ta.atr(14)5var table t = table.new(position.top_right, 2, 3, bgcolor = color.new(#100e18, 0), border_width = 1, border_color = color.new(#3a3352, 0))6if barstate.islast7 table.cell(t, 0, 0, "Close", text_color = color.gray)8 table.cell(t, 1, 0, str.tostring(close, format.mintick), text_color = color.white)9 table.cell(t, 0, 1, "RSI 14", text_color = color.gray)10 table.cell(t, 1, 1, str.tostring(r, "#.0"), text_color = r > 70 ? color.red : r < 30 ? color.teal : color.white)11 table.cell(t, 0, 2, "ATR 14", text_color = color.gray)12 table.cell(t, 1, 2, str.tostring(a, format.mintick), text_color = color.white)

Cells are addressed (column, row), both from 0.

Polylines and linefills#

polyline.new(points) draws a path through an array of chart.points, optionally curved or closed and filled. linefill.new(line1, line2, color) shades between two lines. Both are supported.

Coordinates#

  • By default the x coordinate is a bar index. Pass xloc = xloc.bar_time to use a time in milliseconds instead, for example time or a value from timestamp(...).
  • In a pane script, drawings sit in that pane. Add force_overlay = true to put one on the price chart.
  • Drawings count toward the chart's autoscale, so a label far above price widens the scale to show it.

Note

Script drawings are not chart drawings. They are not added to your object tree or saved layouts; they come back each time the script runs. Some label shapes and table layouts are close to TradingView's but not pixel-identical.

PreviousTechnical analysisNext Multiple timeframes

On this page

  • Labels and lines on the last bar
  • Keeping one object up to date
  • Boxes
  • Tables
  • Polylines and linefills
  • Coordinates

Use with AI

View as MarkdownOpen in ClaudeOpen in ChatGPT