How to fix compile errors in the Pine editor
Updated
The Pine editor checks your script as you type. When it does not compile, the message appears under the failing line and Add to chart is switched off until you fix it. This guide breaks a script on purpose, reads the message and repairs it.
Try it in Zeal TerminalSteps
- Code editor. Write a script with a typo:
closeis misspelledclse. - Compile errors. Errors are listed under the editor and the failing token is underlined in red. Read what the compiler did not understand.
- Fix with AI. Each error row has a Fix with AI button. It asks the assistant to repair that line and shows the change in the editor with Accept and Reject. Signed out, it opens the assistant panel instead.
- Add to chart. While the script does not compile, this button reads "Doesn't compile" and cannot be clicked.
- Code editor. Correct the line. The errors clear as soon as the script compiles.
- Add to chart. Add to chart is available again. Click it to run the script.
Reading the message
Each message names the problem and the line it is on. Start with the first one: later errors are often caused by it, and fixing it can clear several at once.
Common causes
- A misspelled name. A built-in or a variable you never declared is reported as undeclared.
- The wrong version.
ta.smais Pine v5 and v6 syntax; in v4 it issma. Check the//@version=line first. - A missing version line. A script without one is read as Pine v1.
- A bad indent or bracket. Check the line above the one that is flagged.
Let the assistant help
The AI assistant can read the errors, and its "Fix the compile errors" starter asks it to repair the script. See the guide on asking the AI assistant.
Related guides
This guide is replayed by an automated test on every release, so the steps here match the app as it is today.