--> pinefixer: Fixing 'Mismatched Input' in Pine Script (The 5 Most Common Causes)
blog

Fixing 'Mismatched Input' in Pine Script (The 5 Most Common Causes)


"Mismatched input" is probably the single most common error message you'll see in the Pine Editor — and also one of the most confusing, because it rarely points directly at the actual mistake. It tells you the compiler hit a token it didn't expect, not what you did wrong. Here are the five causes that account for most cases.

1. A Missing Comma Between Function Arguments

This is the single most frequent cause. Something like:

plot(close color=color.blue)

is missing a comma after close. The fix is simply plot(close, color=color.blue). Easy to miss when a line has several arguments.

2. An Unclosed Parenthesis or Bracket

If you have more opening ( than closing ) anywhere earlier in the script, the compiler often doesn't fail until several lines later — right where it finally runs out of valid syntax to parse. If the error line looks completely fine, scroll up and count brackets on the lines above it.

3. Mixed Tabs and Spaces in Indentation

Pine Script (v5 and v6) uses indentation to define blocks, similar to Python. If a script mixes tabs and spaces — common when copy-pasting from a forum post or PDF — the parser can lose track of block structure and throw a mismatched input error on a line that looks perfectly normal.

4. A Reserved Word Used as a Variable Name

Words like open, close, high, low, time, and volume are built-in series in Pine. Naming your own variable close or time will sometimes compile fine and sometimes throw confusing errors depending on context — safest to just avoid reusing these names entirely.

5. A Stray Character From Copy-Paste

Curly quotes ( ) instead of straight quotes ("), or invisible Unicode characters picked up from a website or PDF, are a sneaky cause. If a line looks 100% correct but still errors, try retyping it manually instead of trusting the paste.

Don't want to hunt for this manually?

Paste the exact error message into the free Pine Script Error Explainer and get a plain-English breakdown of what it means and how to fix it — no signup required.

Open the Error Explainer →