FAQ
What runs my script?
A locked-down background Web Worker, so the chart stays responsive. On the chart, a terse indicator() body runs once per recompute with the whole history loaded; a class-form onBar() runs once per bar, oldest to newest. The backtester feeds bars one at a time.
Can I use npm packages?
No. A script can only use the names CodeLab provides from @chartlabs/script-sdk (see "Built-in names"). Import lines are removed before the script runs, so a name from any other package, or a name the SDK does not provide, fails with "<name> is not defined".
Does my script have internet access?
No. fetch, XMLHttpRequest and WebSocket are removed in the worker, http.* is not available, and there is no DOM. Scripts only see the chart's bars, which keeps them deterministic, backtestable and safe to share.
How do I debug?
Read the Console under the editor: it shows compile errors and runtime warnings, such as a script that drew nothing. To check values, plot them or show them with table() or label() on the chart.
Can a script place real trades?
No. strategy.* orders are simulated by the CodeLab backtester (the Backtest tab). They are not sent to a broker.