Labels, lines & tables

Labels, lines & tables

For richer overlays, the object primitives mirror Pine’s label / line / box / table / fill / barColor. Unlike plots, these are imperative: call them any number of times.

objects.ts
// Objects are imperative: call them as many times as you like, even in a loop.
// Bar positions count back from the newest bar (0 = newest).
label({ bar: 0, price: close.value, text: 'Now ' + close.value.toFixed(0),
        color: '#fff', bgColor: '#2b8aef', yLoc: 'above' });

line({ x1: 0, y1: close.value, x2: 30, y2: close.at(30), color: '#888', style: 'dashed' });

box({ left: 10, top: high.at(0), right: 0, bottom: low.at(10),
      fillColor: 'rgba(255,235,59,0.08)', borderColor: '#ffeb3b' });

table({ position: 'top-right', cells: [
  { row: 0, col: 0, text: 'RSI', color: '#888' },
  { row: 0, col: 1, text: ta.rsi(close, 14).value.toFixed(1), color: '#fff' },
]});

fill(ta.highest(high, 20), ta.lowest(low, 20), { color: 'rgba(41,98,255,0.08)' }); // shade between two Series
barColor(close.gt(open).and(volume.gt(ta.sma(volume, 20))), { color: '#ffeb3b' }); // recolour candles