charting-library-examples
charting-library-examples copied to clipboard
Error: Value is null when using createPositionLine without delay
Error: Value is null when using createPositionLine in TradingView Widget
Description: The following code throws an error:
Error: Value is null.
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