Pine Script syntax troubleshooting

Fix Pine Script "End of Line Without Line Continuation" Errors

To fix "end of line without line continuation" in Pine Script, inspect the highlighted statement for an unfinished expression, missing delimiter, or invalid continuation indent. Outside parentheses and square brackets, use a continuation indent that is not a multiple of four, such as two spaces globally or six inside a four-space block. Current Pine v6 also allows arbitrary indentation inside parentheses and square brackets. Comments are allowed in wrapped expressions; check that they have not hidden an operator or closing delimiter.

Debug with the Pine Script AI Coding Agent

A four-space continuation can break a ternary

This example isolates the whitespace problem without changing the condition. The invalid assignment is commented out so the complete script remains usable. To reproduce the error, replace the working assignment with the BROKEN fragment and remove its comment prefixes, preserving the four leading spaces. The repair uses two spaces on each continuation line.

Complete v5 script: broken fragment in comments, corrected assignment activepinescript
//@version=5
indicator("Ternary continuation")

// BROKEN: four-space continuation outside parentheses.
// direction = close > open ?
//     1.0 :
//     -1.0

// FIXED: two-space continuation.
direction = close > open ?
  1.0 :
  -1.0
plot(direction, "Direction")

Keep a local block separate from its wrapped expression

Count indentation from the left edge of the editor. In this function, the assignment starts at four spaces and its continuation starts at six. A continuation at eight spaces would fall on another block boundary. The final result and plot call show where the function body ends; do not move the plot into the function while repairing whitespace.

Context outside parentheses or bracketsStatement indentExample continuation indent
Global assignment0 spaces2 spaces
One local block4 spaces6 spaces
Two nested local blocks8 spaces10 spaces
Complete v5 script: four spaces for the function body, six for continuationpinescript
//@version=5
indicator("Local continuation")

signedRange(float source, float reference, float width) =>
    result = source > reference ?
      width :
      -width
    result

plot(signedRange(close, open, high - low), "Signed range")

Check delimiters before adjusting indentation

A missing closing parenthesis leaves a function call unfinished. A missing comma merges arguments, and a ternary missing its colon or false branch leaves an incomplete expression. These can produce related parser errors with different wording. Inspect the entire statement, including the line before the marker. The example repairs only the missing closing parenthesis; it does not alter the plotted value.

Complete v6 script: missing-parenthesis fragment and its corrected callpinescript
//@version=6
indicator("Call delimiter repair")

// BROKEN: the function call never closes.
// plot(close,
//   title = "Close"

// FIXED: each argument is separated and the call closes.
plot(close,
  title = "Close"
  )

Comments do not automatically break line continuation

Both the archived v5 manual and current documentation explicitly allow comments in wrapped statements. A // comment hides the rest of its physical line, so an operator or delimiter written after // is no longer code. In the working example, the plus sign appears before the comment. Moving comments above a statement can help you inspect it, but deleting every comment is not a language requirement.

Complete v5 script: an inline comment within a valid wrapped expressionpinescript
//@version=5
indicator("Comment in a wrapped expression")

priceSum = open + high + // The expression continues below.
  low + close
plot(priceSum / 4.0, "Average OHLC")

Version labels are not the whole wrapping history

The archived v5 manual documents non-multiple-of-four continuation indentation. TradingView later relaxed indentation within parentheses in December 2025 and within square brackets in September 2026. These are dated language updates, not changes that all arrived with the first v6 release. The current v6 example below uses parentheses around the entire ternary. When maintaining older code, the two-space and six-space styles above avoid relying on the newer formatting allowances.

ConstructCurrent documentationPractical check
Expression outside () and []Continuation indent is not a multiple of fourCheck every wrapped line
Inside parentheses ()Any indentation, including zero and four spacesKeep the whole wrapped expression enclosed
Inside square brackets []Any indentation after the September 2026 updateApplies to tuples and history references; [] is not a general array literal
Complete v6 script: a parenthesized ternary with four-space continuationpinescript
//@version=6
indicator("Parenthesized continuation")

direction = (
    close > open ? 1.0 :
    close < open ? -1.0 :
    0.0
)
plot(direction, "Direction")

Reduce the failing statement before changing the script

Use a copy of the script and fix the first reported error first. Temporarily putting the failing expression on one physical line helps separate a wrapping problem from missing syntax. If the single-line form still fails, inspect tokens and delimiters rather than changing indentation again. After it compiles, restore readable wrapping and check that the calculation still produces the intended values.

  • Read the exact message: "mismatched input ... expecting end of line without line continuation" can also indicate unexpected indentation before a separate statement.
  • Retype suspicious leading whitespace with spaces so tabs and copied formatting do not obscure the count.
  • Preserve the script version while diagnosing. A version migration can introduce unrelated changes.
  • Editor word wrap only changes display. A physical newline in the source is what matters to this error.
  • When asking for help, include the version line, complete failing statement, enclosing block, and exact compiler message.
Where Pineify fits

Pine Script AI Coding Agent

Paste the failing script and compiler message into Pineify to request a diagnosis and proposed correction. Review the change and compile the result in TradingView before relying on it.

Debug with the Pine Script AI Coding Agent

Frequently asked questions

These examples explain syntax, not trading performance. Compile the complete script and inspect its behavior in TradingView after applying a repair.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.