Root causes
- A local block has no indented statement after its header.
- A wrapped expression uses indentation that Pine interprets as a new block or global statement.
- A missing closing delimiter on the previous line makes the next token unexpected.
Indent every statement that belongs to an `if`, `for`, function, or other local block by four spaces or one tab. The unindented `label.new()` line ends the block before Pine finds its body, so the parser reports mismatched input. Moving the line into the block restores the required script structure. If a different token is named, inspect the line immediately before it as well.
This link opens the Pine Script AI Coding Agent overview. It does not run or change code on this page.
Before and after
Both artifacts include the version declaration and the code needed to inspect the stated problem. The diff lists the lines that change between them.
//@version=6
indicator("Mismatched input demo", overlay = true)
if close > open
label.new(bar_index, high, "Up")//@version=6
indicator("Mismatched input demo", overlay = true)
if close > open
label.new(bar_index, high, "Up")--- broken.pine
+++ fixed.pine
@@
if close > open
-label.new(bar_index, high, "Up")
+ label.new(bar_index, high, "Up")Continue with a guide that shares the same scope, type, history, or resource mechanism.
Compilation error
Compilation error
Open the Coding Agent overview to paste editable Pine Script, explain the intended behavior, and request a review. Compile and test the result in TradingView before using it.
Paste your code to fix this error