Skip to main content

indicator.plot#

Emit a single line value at the current bar inside onBar.

SYNTAX#

function plot(label: string, value: number, opts?: { color?: string; width?: number; style?: 'solid' | 'dashed' | 'dotted' }): void

ARGUMENTS#

  • label (string) — Series identifier. Bars sharing the same label form a single rendered line.
  • value (number) — Numeric value at the current bar. Use NaN for gap bars; the renderer breaks the line.
  • opts ({ color?: string; width?: number; style?: 'solid' | 'dashed' | 'dotted' }) — Optional rendering hints. Defaults: color #888, width 1.5, style solid. The first non-default value seen for a label sticks for the whole series.

RETURNS#

void

REMARKS#

Silently no-ops if label is not a string or value is not a number — does not throw. Only callable inside onBar; outside of a per-bar callback the current bar index is undefined. Lines have no opacity property — encode transparency in color with rgba(...) or 8-digit #RRGGBBAA hex instead. Style and width are fixed at first emission: the first plot() call for a label locks that series' color/width/style for the rest of the run.

EXAMPLE#

function onBar(i, ctx) {
  plot('close', candles[i].close, { color: '#00ff88', width: 2 });
  plot('open',  candles[i].open,  { color: '#ef5350', width: 1, style: 'dashed' });
}

SEE ALSO#

indicator.plot.histogram, indicator.plot.marker, indicator.plot.candle, indicator.onBar