Pine Script tool
Pine Script Error Decoder
Paste the error message TradingView gave you. This identifies which error it is, explains what the compiler is actually objecting to, and links to a full teardown of that specific failure.
Paste an error message above to identify it. Every error this recognises is listed further down the page if you would rather browse.
Why Pine Script errors point at the wrong line
The single most confusing thing about debugging Pine Script is that the line the editor highlights is frequently not the line with the mistake. This is not a flaw so much as a consequence of how a compiler works. It reads your source from top to bottom, building up an understanding of the structure as it goes, and it can only complain at the moment something becomes impossible. A parenthesis you forgot to close is perfectly legal at the point you forgot it, because a closing parenthesis might still arrive. The error appears on the next line that cannot possibly follow.
The practical habit that follows is to treat the highlighted line as the end of a search rather than the beginning of one. Read backwards from it, one complete expression at a time, looking for the point where something was left unfinished. This is much faster than staring at the flagged line, which often looks entirely reasonable because it is.
There is a second category that behaves differently. Runtime errors happen after a successful compile, while the script is processing bars, and those messages usually do identify the right line. The distinction matters because it tells you where to look: a compile error is a structural problem in the text, while a runtime error is a problem with a value that only existed once the script started running.
Fix one error at a time, from the top
When the console lists several errors, resist the urge to read all of them. Errors cascade, so a single missing bracket can generate four or five downstream complaints that have no independent existence. Fix the first one, recompile, and look again. It is common for a list of five errors to collapse to zero after one character changes.
This is also the strongest argument against handing a compile error to a general-purpose chat assistant and accepting a whole regenerated script. Most Pine Script errors have one small, local cause. A full rewrite replaces code that was already correct, which means you have traded a known one-line problem for an unknown number of new ones, and you no longer have the compiler's original clue to work from.
Every error this decoder recognises
The catalogue below is what the decoder matches against. If your message is not here, that is worth knowing rather than papering over, which is why an unmatched paste returns nothing instead of a plausible guess.
- Undeclared identifier — compile
- Could not find function or function reference — compile
- Mismatched input — compile
- Cannot use "plot" in a local scope — compile
- Script requesting too many securities — compile
- Pine cannot determine the referencing length of a series — runtime
- End of line without line continuation — compile
- Maximum number of labels, lines, or boxes reached — runtime
- Add to Chart operation failed, script could not be translated — compile
- Cannot call with arguments of that type — compile
- Boolean condition cannot be na (v6 strict booleans) — compile
- Unknown argument (when, transp, or another removed parameter) — compile
- Runtime error after a successful compile — runtime
- Calculation takes too long, or memory limits exceeded — runtime
- Strategy compiles but places no trades — behavior
Fix the error without rewriting the script
The code above is the shape of the most common Pine Script error there is. A variable assigned inside an if block does not exist outside it, so the plot() call cannot see it. The fix is two lines: declare it in the global scope with var, then assign to it inside the block with := rather than =. Notice how small the correct fix is compared with regenerating the script.
//@version=6
indicator("Undeclared identifier, the usual shape of it")
// Broken: highestClose is declared inside the if block, so it does not
// exist on the plot line below.
// if barstate.islast
// highestClose = ta.highest(close, 50)
// plot(highestClose)
// Fixed: declare it in the global scope, assign to it with := inside.
var float highestClose = na
if barstate.islast
highestClose := ta.highest(close, 50)
plot(highestClose, "Highest close")PineScripter is an AI built specifically for Pine Script. You describe what you want in plain English and it writes TradingView-ready v6 code. Because it is specialized on the Pine Script language and its exact function signatures, it tends to produce code that compiles far more reliably than general-purpose models like ChatGPT, which often invent functions that do not exist in Pine Script.
Related free calculators
From the blog
PineScripter is an AI developer tool that helps you write Pine Script code. It is not a financial advisor and will never offer financial, investment, or trading advice. Everything on this page, including the calculator and the explanations, is provided purely for educational and informational purposes. Any decision about how to interpret an indicator or trade a market is entirely your own. See our full disclaimer for more.