plot.candle#
Emit one OHLC tuple at the current bar to render an overlay candle.
SYNTAX#
function plot.candle(label: string, ohlc: { o: number; h: number; l: number; c: number }, opts?: { color?: string; wickColor?: string; bullishColor?: string; bearishColor?: string }): voidARGUMENTS#
label(string) — Candle series identifier. One series per label.ohlc({ o, h, l, c }) — Open / high / low / close numeric tuple. All four fields are required and must be finite numbers.opts({ color?, wickColor?, bullishColor?, bearishColor? }) — Defaults: bullishColor#26a69a(orcolor), bearishColor#ef5350(orcolor), wickColor#888(orcolor).
RETURNS#
void
REMARKS#
Bars where you skip emitting a tuple render as null (no candle). Body color is chosen from c >= o per bar.
EXAMPLE#
function onBar(i, ctx) {
// Heikin-Ashi smoothing
const c = candles[i];
const haClose = (c.open + c.high + c.low + c.close) / 4;
const haOpen = i === 0 ? c.open : (ctx.state.haOpen + ctx.state.haClose) / 2;
ctx.state.haOpen = haOpen;
ctx.state.haClose = haClose;
plot.candle('ha', { o: haOpen, h: c.high, l: c.low, c: haClose });
}SEE ALSO#
indicator.plot, indicator.plot.histogram, indicator.plot.marker