Skip to main content
You write scripts in the Lipi editor and check them there. A check parses the script, resolves every name and checks every type without running it against any bars. A clean check means the script is well formed; it does not mean it will run or that it will be accepted on the chart. This page lists what each phase checks. The check reads the first //@lipi=N line: N equal to 2 checks the script as Lipi v2, and with no line, or //@lipi=1, it is checked as Lipi v1 (see Moving a script from Lipi v1 to v2).

Three phases

What a check reports

Each problem has a start and an end position (line and column) and a message, and comes in one of two groups.
  • Errors stop the script. A script with several syntax errors shows only the last one found, and a name or type error usually stops at the first one, so fix what is reported and check again.
  • Warnings do not stop the script. Examples: Unreachable code detected., opacity 50 is outside 0–1; 1 is solid, Do not use the `na` variable to compare other values to 'na', use the `na()` function instead, and Variable `line` hides the built-in namespace `line`.
A clean check also returns what the script resolved to: its variables with their types, its functions with their signatures, its types and enums, and its scopes. For this script
the check lists the variables h (series float) and b (series bool), the function half(series float a) → series float, the type P with its field v, and the enum E with its member A. Use it to see what an unfamiliar script declares.

What a clean check does not prove

Rules that apply only when the script is added to the chart

These pass the editor’s check and fail on Add to chart: A literal na for an input argument is refused by the editor’s check itself.
The compiler says, on Add to chart: The format argument of indicator() only accepts format.inherit, format.price, format.volume, or format.percent. Got format.mintick.

Errors that happen while the script runs

The check never executes the script, so it cannot see these:
  • A history index above 500: close[501] passes both checks and stops the script with “The script is trying to access historical data outside allowed range (501). The allowed range is 0 to 500.”
  • An array index outside the array: array.get(a, 0) on an empty array stops the script (see Arrays).
  • A for loop whose step points the wrong way, a drawing text over 999 characters, an array over 10,000 elements.
  • A script that runs longer than 45 seconds on the chart’s history is cancelled.
  • A strategy direction that is not strategy.long or strategy.short, such as strategy.entry("L", "buy").
  • Orders and results: a clean check of a strategy runs no bars, so it shows no orders, trades or equity. Add the script to the chart to see them.
Read Limits for the numbers, and test a script on a chart before you rely on it.