Plotting candlesticks - is it possible?

Hi,

Does anyone know if it’s possible to plot custom candlesticks with my own OHLC values that I specify? I’ve only seen ways to plot points and lines, but not candlesticks.

Unfortunately that is not currently supported.

Circling back for others who want to see what @nom28 cleverly came up with for his excellent Smoothed Hieken Ashi indicator… combined with setting the base chart colors to transparent, you can simulate drawing candles using two lines, a thick one for the body and a thin one for the wicks… the key limitation that it will only look clean if the same colors are used for body and wicks, and no empty bodies, etc…

function candlestickPlotter(canvas, indicatorInstance, history) {
  for(let i=0; i<history.data.length; ++i) {
    const item = history.get(i);
    if (item.haOpen !== undefined
            && item.haHigh !== undefined
            && item.haLow !== undefined
            && item.haClose !== undefined) {
        const x = p.x.get(item);
        
        // candle body
        canvas.drawLine(
            p.offset(x, item.haOpen),
            p.offset(x, item.haClose),
            {
                color: item.haOpen > item.haClose ? indicatorInstance.props.fallingColor : indicatorInstance.props.risingColor,
                relativeWidth: 0.9,
            });
        
        // candle wicks   
        canvas.drawLine(
            p.offset(x, item.haHigh),
            p.offset(x, item.haLow),
            {
                color: item.haOpen > item.haClose ? indicatorInstance.props.fallingColor : indicatorInstance.props.risingColor,
                relativeWidth: 0.2,
            });
    }
}

}

1 Like