A syntax error means the compiler cannot parse the script structure. Start at the reported line, then inspect the preceding lines for an unclosed bracket, quote, malformed expression, incorrect indentation or version-incompatible syntax.
What you may be seeing
- The Pine Editor highlights a token with a syntax error
- The reported line looks correct by itself
- The error appeared after editing a multiline expression or migrating code
Most likely causes
- A parenthesis, bracket, quote or block is not closed correctly
- A comma, operator or function argument is missing or misplaced
- Indentation or syntax does not match the declared Pine version
Try this first
- Read the first compiler error before later cascading errors
- Inspect the reported line and several lines immediately above it
- Balance all delimiters and check commas, operators and indentation
- Reduce the statement to a minimal compiling form, then restore one part at a time
If that didn’t fix it
- Reformat a complex expression into named intermediate variables
- Compare the construct with the current Pine Script reference
- Create a small test script that contains only the failing block
Verify the fix
The editor compiles with no syntax errors and the restored expression produces the expected output on a known chart.
Why this happens
A syntax error means the compiler cannot parse the script structure. Start at the reported line, then inspect the preceding lines for an unclosed bracket, quote, malformed expression, incorrect indentation or version-incompatible syntax.
The highlighted token is often where parsing finally failed, not where the mistake began. Reduce the failing statement to a small valid form and add its parts back one at a time.