TradingView Leightweight charts previous day in callback from chart.subscribeCrosshairMove

TradingView has a sample here on how to retrieve the current price bar under the mouse position and write that data in a div. But I also want to show the percentage move since yesterdays close. Then I need to retrive the previous days bars. And I am having trouble figuring out how to do that.

I do something like this now:

 chart.subscribeCrosshairMove((param) => {
            if (param.time) {
                const data = param.seriesData.get(candleSeries);
                const vdata = param.seriesData.get(volumeSeries);
                stockInfoRow.innerHTML = '<div style="font-size: 20px; margin: 4px 0px; color: #20262E">' + symbol + '</div>' +
                    '<div style="font-size: 14px; margin: 4px 0px; color: #20262E">' + '  O' + data.open + ' H' + data.high + ' L' + data.low + ' C' + data.close +
                    ' Vol' + formatVolume(vdata.value) + '</div>';
            }
        });

Leave a Comment