Read the Problems list, print values to the Console, and find slow lines with the Profiler.
Under the code, Problems lists every error and warning with its line and column. Click one to jump there. The same spot is underlined in the code; hover it for the message. A script with errors cannot be added to the chart.
//@version=6 indicator("Debug Console", overlay = true) len = input.int(14, "Length", minval = 1) rsi = ta.rsi(close, len) // Messages appear in the Console under the editor. if barstate.islast log.info("RSI({0}) = {1}", len, rsi) if rsi > 70 log.warning("Overbought: {0}", rsi) // A value shows in the Data window when you hover a bar. plot(rsi, "RSI", display = display.data_window)
log.info, log.warning and log.error write to the Console tab while the script is on the chart. {0} and {1} are replaced by the values. If a script stops with a runtime error, it appears there with the bar it happened on.
log.info
log.warning
log.error
{0}
{1}
Open the Profiler tab and switch it on. Every line shows how many times it ran and how long it took, and the slowest lines are listed. The script runs slower while it is on, so switch it off when you are done.
=
:=
fill
hline
var
ta.sma(close, 200)
A bar may use 200 ms of calculation and a whole run 20 seconds. Scripts can use up to 64 plots, 500 drawing objects of each kind and 100 000 values in one array. A script that goes over a limit stops with a message that says which one.