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

# House style and naming

> The one spelling to use where Lipi v2 accepts several, and the naming conventions for scripts shared on GoCharting.

Lipi accepts several spellings for some things. This page picks one so that scripts read alike. Breaking a rule is never an error.

## One spelling

* **Logic:** `and`, `or`, `not`, not `&&`, `||`, `!` (the same tokens).
* **Functions:** `func spread(float h, float l) => h - l`. The keyword-less form compiles too; `def` declares a method, not another spelling.
* **Body:** an arrow while the body is one expression; braces and `return` from two statements.
* **Parameters:** write the type; add a qualifier (`const`, `simple`) only to restrict. The default is `series`.
* **Analysis:** `talib.sma(...)`; `ta.sma(...)` is the same namespace.
* **Persistence:** `static`, or `intra` for a value kept across the ticks of one forming bar only; declare them after the inputs, assign with `:=`. `var` does not exist.
* **Arrays:** `array.new<float>(0)` and the method form `a.push(x)`.
* **Drawings:** create once into a `static` variable and change it with `set_*`.
* **Strategy ids:** one string constant per order id.
* **Absence:** `na(x)`, not `x == na` (a warning).
* **Enumerated arguments:** `plotStyle.histogram`, `display.pane`, `size.small`, not strings or numbers.
* **Colors:** `color.red` or `#RRGGBB`; fade with `color.new(color.red, 0.7)` (opacity 0 to 1).
* **Arguments:** name every argument after the second: `plot(x, title="Spread", color=color.red)`. `step=` may be named.

## Layout

* Order: `//@lipi=2`, the declaration, inputs, calculations, then `plot` and other output calls.
* One statement per line, four spaces per block level, `else` on the line of the closing `}`. Break a long statement after a comma or an operator, never before one.
* Comparisons do not chain and have unusual precedence: write `a < b and b < c`, and parenthesise mixed conditions.

## Names

* Variables, functions, arguments: lowerCamelCase (`fastLength`).
* Types, enums and their members: UpperCamelCase (`Swing`, `Speed.Fast`).
* Never reuse a built-in name (rules in [Names and conventions](https://gocharting.com/docs/scripting/language/names-and-conventions.md)).

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Range ratio")
length = input.int(14, "Length", minval=1, maxval=200)
func ratio(float a, float b) => b == 0 ? na : a / b
avgRange = talib.sma(high - low, length)
plot(ratio(high - low, avgRange), title="Range ratio", color=color.blue)
hline(1.0, title="Average", color=color.gray)
```


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