Skip to main content

chart.isFirst#

True on the first bar of the warmup loop (i === 0).

SYNTAX#

ctx.isFirst: boolean

RETURNS#

boolean — true exactly once per warmup pass.

REMARKS#

Always false in tick mode (since tick mode invokes onBar only at i = N - 1).

EXAMPLE#

function onBar(i, ctx) {
  if (ctx.isFirst) {
    ctx.state.cvd = 0;
  }
  ctx.state.cvd += candles[i].close >= candles[i].open ? candles[i].volume : -candles[i].volume;
  plot('cvd', ctx.state.cvd);
}

SEE ALSO#

chart.isLast, chart.isHistory, chart.isRealtime