charting-library-examples icon indicating copy to clipboard operation
charting-library-examples copied to clipboard

Error: Value is null when using createPositionLine without delay

Open money-development opened this issue 1 year ago • 0 comments

Error: Value is null when using createPositionLine in TradingView Widget

Description: The following code throws an error:

Error: Value is null.

image
window.tvWidget.onChartReady(() => {
    window.tvWidget
        .activeChart()
        .createPositionLine();
});

However, adding a delay resolves the issue:

window.tvWidget.onChartReady(() => {
    setTimeout(() => {
        window.tvWidget
            .activeChart()
            .createPositionLine();
    }, 500);
});

Expected Behavior: createPositionLine should work without needing a delay

money-development avatar Jan 10 '25 09:01 money-development