> ## Documentation Index
> Fetch the complete documentation index at: https://gocharting.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Why Lipi exists

> Where Lipi comes from, how the language is defined, how its versions are told apart, and what this manual describes.

Lipi is GoCharting's own scripting language. It exists so that you can put your own calculations on a GoCharting chart, as an
indicator or as a strategy, in a language that GoCharting defines, checks and maintains with the platform.

## A small language

Lipi keeps its surface small. A statement is one line. A block is written with braces over several lines. A script declares what it
is with one call, `indicator(...)` or `strategy(...)`, and the platform evaluates it once for every bar. What the script produces
(plots, drawings, tables, alerts, strategy orders) goes through a fixed set of calls, listed in the reference.

## How the language is defined

Lipi is defined by an ANTLR grammar and implemented in Go, in GoCharting's own codebase. The grammar decides what parses. The
compiler decides which parsed scripts are accepted, and the interpreter decides what they do when they run. All three are
maintained together with the platform, so a name in the language is a name in GoCharting's compiler.

## Versions

Lipi has two versions. The first line of a script selects one: `//@lipi=2` selects Lipi v2, and a script without the line is read as
Lipi v1. Lipi v2 adds arrays, drawings, tables and strategies, and the editor checks a script against the rules of the version it
selects. This manual describes Lipi v2; see [Moving a script from Lipi v1 to v2](https://gocharting.com/docs/scripting/getting-started/migrating-from-v1.md) for
what changes.

## What this manual describes

This manual describes the language as the compiler implements it. Where the manual and the compiler differ, the compiler is right
and the manual has a bug. Pages say which phase enforces a rule: the editor's check, adding the script to the chart, or running the
script (see [The Lipi editor](https://gocharting.com/docs/scripting/getting-started/editor.md)). The [reference](https://gocharting.com/docs/scripting/reference/functions/global.md) lists every function,
variable, constant, type and keyword; the manual explains how they fit together.

The smallest complete script declares itself and plots one value:

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Closing price")
plot(close)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.