Pine Script code checker and fixer: find and fix script errors online
Check Pine Script code online for free: SuperCharting's Script Editor finds errors with line numbers, and Auto-fix repairs common mistakes for you.
A Pine Script code checker tells you whether a script will compile and run, and where it breaks if it will not. SuperCharting's Script Editor does this in the browser: it checks your code as you type, points to the line of each error, and has an Auto-fix button that repairs common mistakes and lists every change it made. It is free for now and needs no install. Pine Script is TradingView's language; SuperCharting runs scripts written in the same version 6 syntax in its own engine, and the Pine compatibility page lists which features are supported.
How to check a Pine Script for errors
- Open a chart, then open the Script Editor with Ctrl + E or the Script Editor button in the right-hand bar.
- Paste your script into the code area, replacing the starter template.
- About 600 milliseconds after you stop typing, the console shows the result:
- ✓ My script (indicator) when it compiles;
- ✗ line 6: unexpected 'EOF' (or a similar message) when it does not. A red dot appears on the console button, and the console opens on its own.
- Click Add to chart. Some mistakes show only when the script runs on real bars, such as a misspelt function name. Those appear as a line that starts with Runtime:, again with the line number, for example
Runtime: line 3, bar 0: unknown function ta.foo().
So there are two checks: the compile check while you type, and the run check when the script goes on the chart. A script that passes both is ready to use.
What Auto-fix repairs
When the console shows an error, press Auto-fix, the button right after Save in the editor header. The console shows "Auto-fix: reading your script…". It then puts the fixed version in the editor and lists each change in plain words, for example "Line 3: tab indent replaced with 4 spaces." The last line tells you where the script stands: ✓ The script compiles and runs, or ✗ Still wrong with the line that still has a problem. If you do not like the result, choose Undo Auto-fix in the More menu to get your original back.
The built-in fixer, on every account, handles two kinds of problem:
- Old-version code. For a script with no
//@versionline or a version below 6, it: - sets
//@version=6; - turns
study()intoindicator(), and addsindicator()if it is missing; - adds the missing namespace to old functions (
smabecomesta.sma,maxbecomesmath.max,tostringbecomesstr.tostring,securitybecomesrequest.security); - rewrites
iff(c, a, b)asc ? a : b; - changes
input(x, type=input.integer)toinput.int(x); - changes bare colour names to
color.redand friends, andtransp=Ntocolor.new(c, N); - replaces
x == nawithna(x); - changes
=to:=when a variable declared earlier is given a new value. - Characters that broke the script. Curly quotes, a tab indent or a semicolon at the end of a line become plain quotes, 4 spaces or nothing. It does this only when that character is what broke the script.
- The error the checker reports. It repairs an unclosed string or bracket, a stray character, and a misspelt function, variable or colour name (it picks the closest known name). Then it checks again, and repeats until the script runs or nothing more can be fixed.
Auto-fix never edits text inside strings or comments, except the quote characters themselves. If a change would leave the script worse than before, that change is dropped. Every account can run Auto-fix up to 40 times an hour.
The deeper AI check
For accounts the site owner enables, Auto-fix also runs an AI pass after the built-in one. It can fix what simple rules cannot, such as a missing comma between arguments or a block indented wrongly. The console then says "Auto-fix (full AI check)". The AI result is checked again in the same way, and it is kept only if it is no worse than the built-in fixer's. Like any AI it can be wrong, so read the list of changes before you rely on the script.
Common Pine Script errors and what they mean
| Console message | Usual cause | Fix |
|---|---|---|
unexpected 'EOF' | A bracket or string was opened and never closed | Close it. Auto-fix does this for you |
unknown function ta.foo() (Runtime) | A misspelt or non-existent function | Correct the name. Auto-fix picks the closest real one |
An error on study( | Code from Pine version 4 or older | Auto-fix converts it to indicator( and version 6 |
An error on sma( or rsi( without ta. | Version 4 functions had no namespace | Auto-fix adds ta. or math. |
| A variable cannot be reassigned | = used where := is needed | Auto-fix changes it when the variable was declared before |
After the check passes
- Save with Ctrl + S. Scripts are saved to your account, up to 500 of them.
- Turn an indicator into a strategy and test it in the Strategy Tester. The backtest Pine Script online guide walks through it.
- If you are new to the language, Pine Script v6 basics and write your first indicator explain the syntax with examples that run.
What the checker does not do
- It does not promise that every Pine Script feature runs. Some built-ins are not supported yet, and the console names them. For example,
request.securityworks on higher timeframes of the chart's own symbol, but not on a different symbol. - It checks that the code runs, not whether a strategy is any good. A script that compiles can still lose money, and nothing here is investment advice.
TradingView and Pine Script are trademarks of TradingView, Inc. SuperCharting is independent and not affiliated with it.