All free tools

Pine Script tool

Pine Script Validator

Paste a script to check the things that are cheap to catch from the text: an unbalanced bracket, an output function inside an if block, a function name that no longer exists, indentation that mixes tabs and spaces. It runs entirely in your browser and nothing is uploaded.

3 findings

3 that would stop it compiling, 0 worth reviewing.
  • Will not compileLine 7

    Unclosed "("

    This delimiter is never closed. Pine will report the error at the next line that cannot legally follow, which is usually further down than this one, so start here.

  • Will not compileLine 7

    "sma()" does not exist in v5 or v6

    It was renamed when namespaces were introduced. Use ta.sma instead. This is the single most common symptom of code written for an older Pine version, or of a general AI model producing a name that sounds right.

  • Will not compileLine 10

    plot() called in a local scope

    plot() declares a permanent output rather than performing an action on the current bar, so it can only be called at the top level. Move it out and make the value conditional instead of the call: compute a series that is na when you want nothing drawn.

What this checks, and what it cannot

Being clear about the boundary matters more than the feature list. This page performs static checks on the text of your script. It reads the version annotation, counts delimiters after removing strings and comments, looks at indentation, and matches a list of function names that were renamed when Pine introduced namespaces. Every one of those is a mistake that is common, unambiguous, and visible without understanding what the script means.

It is not a compiler. It does not build a syntax tree, resolve types, or evaluate anything, so it cannot tell you that a parameter needs a simple int rather than a series, that a variable is used before it is declared, or that a function is called with the wrong number of arguments. Those require the real thing, and the real thing is the Pine Editor on TradingView, which is free and authoritative. Nothing here replaces pasting the script in and pressing Add to Chart.

The reason a text-level check is still worth running is the ratio. A large share of the errors people actually hit are structural rather than semantic: a bracket that was never closed, a plot moved inside a conditional, a name from an older version of the language. Catching those before the round trip saves the round trip. When this page reports nothing, treat that as having cleared the obvious mistakes, not as a verdict.

The three severities

Findings marked as stopping compilation are the ones where the language rule is unambiguous. An unclosed parenthesis, a function name that does not exist, an output function inside a local block: these will be rejected, and the fix is not a matter of taste.

Findings marked as behaviour changes are things that compile and do something other than what you probably intended. Mixed tabs and spaces belong here because the script may compile today and break the moment someone edits it in a different editor. So does a comparison against a timeframe string that can never be true.

Findings marked as needing your decision are exactly that. Drawing objects used without raising the allowance is not wrong, it depends on how many you create and whether losing the oldest matters to you. A large number of security requests may be fine or may be about to hit a platform limit. These are flagged so you have considered them, not so you change them.

Why structural errors point at the wrong line

One thing worth internalising, because it applies to whatever the Pine Editor eventually tells you as much as to this page: a compiler can only complain at the moment something becomes impossible, which is usually after the mistake. An unclosed bracket is perfectly legal where you left it, because a closing bracket might still be coming. The error surfaces on the next line that cannot possibly follow.

So when a line number looks wrong, read backwards from it rather than staring at it. This page reports the line where a delimiter was opened rather than where the parser gave up, which is usually more useful, but the habit is what matters. Our teardown of "mismatched input" works through the technique in detail, and the error decoder identifies a message once you have one.

The sample script, corrected

The default sample has three deliberate problems, and the corrected version above shows what each fix looks like. sma() becomes ta.sma() because bare indicator names moved into namespaces. The call gets its closing parenthesis. And the plot() comes out of the if block, with the value made conditional instead of the call, because na draws nothing.

That third fix is the one worth remembering, since it is a pattern rather than a typo. Output functions declare a permanent output for the whole script, so they cannot be conditional. Anything you want to appear only sometimes is expressed as a series that is na the rest of the time.

Pine Script v6
//@version=6
indicator("The same script, corrected", overlay = true)

length = input.int(14, "Length", minval = 1)

// Namespaced function name, and the call is closed.
average = ta.sma(close, length)

// plot() belongs in the global scope. Make the value conditional
// instead of the call: na draws nothing.
plotValue = close > average ? average : na
plot(plotValue, "Average", color = color.teal)

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.