> ## 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.

# Scripting on GoCharting

> What Lipi v2 is, what an indicator or a strategy script can produce, what it cannot do, and where to start.

Lipi is GoCharting's own scripting language. A script runs once for every bar of the chart and puts its results back on that
chart: lines, marks, drawings, tables, alerts and, for a strategy, a simulated trading record. This is the manual for Lipi v2, which runs in Terminal V2; the Classic Terminal runs scripts written for Lipi v1.

## Indicator or strategy

A script declares what it is, once, with `indicator(...)` or `strategy(...)`.

* An **indicator** calculates values and shows them. See [Script anatomy](https://gocharting.com/docs/scripting/language/anatomy.md).
* A **strategy** does the same and also places orders with `strategy.entry`, `strategy.close` and the other `strategy.*` calls.
  The orders are simulated: they fill against the chart's own bars on an account inside the script engine, so a strategy is a
  backtest. No function in the language sends an order to a broker. To hand a signal to another system, use alerts and webhooks
  (see [Alerts](https://gocharting.com/docs/scripting/automation/alerts.md) and [Webhooks for algo trading](https://gocharting.com/docs/scripting/automation/webhooks.md)). See
  [Strategies and backtesting](https://gocharting.com/docs/scripting/strategies/overview.md).

## The first line

Every Lipi v2 script starts with `//@lipi=2`. It selects the language version. A script without it is read as Lipi v1, an older
version with a smaller set of names and other rules (see [Moving a script from Lipi v1 to v2](https://gocharting.com/docs/scripting/getting-started/migrating-from-v1.md)).

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)
```

## What a script can produce

| Output | Written with | Where to read |
| - | - | - |
| Lines, histograms, marks, bar and background colors | `plot`, `plotshape`, `plotchar`, `plotarrow`, `plotbar`, `plotcandle`, `hline`, `fill`, `bgcolor`, `barcolor` | [Plotting](https://gocharting.com/docs/scripting/chart-output/plotting.md) |
| Labels, lines, boxes, line fills, polylines | `label.new`, `line.new`, `box.new`, `linefill.new`, `polyline.new` | [Lines, labels, boxes and polylines](https://gocharting.com/docs/scripting/chart-output/drawings.md) |
| Tables of values on the chart | `table.new`, `table.cell` | [Tables](https://gocharting.com/docs/scripting/chart-output/tables.md) |
| Alerts | `alert`, `alertcondition` | [Alerts](https://gocharting.com/docs/scripting/automation/alerts.md) |
| Orders, positions, trades and equity (strategies) | `strategy.*` | [Reading a strategy's results](https://gocharting.com/docs/scripting/strategies/strategy-results.md) |
| Settings the chart user can change | `input.*` | [Inputs](https://gocharting.com/docs/scripting/configuration/inputs.md) |

## What a script cannot do

These limits are enforced by the compiler.

* **Read another symbol or another interval.** There is no `request` namespace; a script sees the symbol and interval of the chart
  it runs on (see [Instrument properties](https://gocharting.com/docs/scripting/market-data/instrument.md) and [Sessions and intervals](https://gocharting.com/docs/scripting/market-data/sessions-and-intervals.md)).
* **Send an order to a broker.** Strategy orders exist only inside the simulation.
* **Look back more than 500 bars.** `close[501]` stops the script when it runs.
* **Load other code.** There is no `import`, and `library()` is not available.
* **Use maps or matrices.** Collections are arrays.
* **Keep an unlimited number of drawings.** Each kind has a limit, 50 by default (see [Limits](https://gocharting.com/docs/scripting/distribution/limits.md)).

## Where to start

> [card] [Why Lipi exists](https://gocharting.com/docs/scripting/lipi-genesis.md)
>
> where the language comes from and how it is defined.

> [card] [Write your first script](https://gocharting.com/docs/scripting/getting-started/first-script.md)
>
> a working indicator in a few lines.

> [card] [The Lipi editor](https://gocharting.com/docs/scripting/getting-started/editor.md)
>
> how a script is checked, and what a clean check does not prove.

> [card] [Reading someone else's script](https://gocharting.com/docs/scripting/getting-started/reading-scripts.md)
>
> how to find your way in a script you did not write.

> [card] [Names and conventions](https://gocharting.com/docs/scripting/language/names-and-conventions.md)
>
> the Lipi spelling of what other languages call differently.

> [card] [What Lipi does not do](https://gocharting.com/docs/scripting/getting-started/not-supported.md)
>
> names and forms that do not exist, and what to write instead.

> [card] [Moving a script from Lipi v1 to v2](https://gocharting.com/docs/scripting/getting-started/migrating-from-v1.md)
>
> the header, what v2 adds and what to check.

> [card] [The reference](https://gocharting.com/docs/scripting/reference/functions/global.md)
>
> every function, variable, constant and keyword.

> [card] [Tutorials](https://gocharting.com/docs/scripting/learn/add-an-input.md)
>
> build one complete script step by step.


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