Zeal TerminalOpen the chart
Zeal Terminal / Guides

How to fix compile errors in the Pine editor

Updated 26 November 2026

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 Terminal

Steps

  1. Code editor. Write a script with a typo: close is misspelled clse.
  2. Compile errors. Errors are listed under the editor and the failing token is underlined in red. Read what the compiler did not understand.
  3. 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.
  4. Add to chart. While the script does not compile, this button reads "Doesn't compile" and cannot be clicked.
  5. Code editor. Correct the line. The errors clear as soon as the script compiles.
  6. 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.sma is Pine v5 and v6 syntax; in v4 it is sma. 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

  • How to apply a Pine Script to the chart
  • How to read Pine logs: log.info and the filters
  • How to ask the AI assistant: explain results and edit code

This guide is replayed by an automated test on every release, so the steps here match the app as it is today.

PricingContactRefundsPrivacyTermsCookiesDisclaimer

© 2026 Zeal Terminal. An independent project, not affiliated with TradingView, Inc.