{} is accepted). This page lists where a statement may continue on the next line and the layouts the compiler refuses, with the
message it gives for each.
The first line
Every Lipi v2 script starts with the line//@lipi=2. A script without it is read as a Lipi v1 script, an older language with
other rules, so it may fail or behave differently. The next statement declares the script, once: indicator(...) for an
indicator, strategy(...) for a strategy (see Strategies and backtesting).
indicator(), strategy(), or
library(); found 0 ((none)).
One statement to a line
Put each statement on its own line. A semicolon does not separate statements:a = close and b = open on two lines. When several
lines are joined this way, the compiler reports only one of them, so fix them all before checking again.
Indentation does not matter to the compiler; indent blocks by four spaces for readers. Names are case-sensitive: x and X are
two variables. A comment starts with // and runs to the end of the line, on a line of its own or after a statement.
Blocks
if, else, loops, switch, function bodies, type and enum use braces. The opening brace stays on the line that starts the
block, and the block’s statements go on the lines after it, never on the same line as a brace:
else may follow the closing brace on the same line, as above, or start the next line. The opening brace may not move to the
next line: if close > open followed by { on its own line is refused with extraneous input ‘\n’ expecting ’{’.
Continuing a long statement
A statement may continue on the next line where the line clearly cannot end:- after a comma or an opening parenthesis, inside the arguments of a call;
- after an operator (
+,-,*,/,and,or, a comparison), at the end of the line; - after
=,:=or=>; - after the
?and the:of a conditional expression.