Language Basics
Every Navi script begins with a declaration statement: indicator(), strategy(), or library().
Script Structure
indicator("My Indicator");
// Your code here
plot(close);Navi uses brace blocks { } and semicolons ; to terminate statements. Newlines are insignificant — you can split or join lines freely.
Comments
// Single-line comment
let a: float = 10; // End-of-line commentThere are no multi-line comments. Special comments starting with //@ are documentation tags: //@function, //@param, //@returns, //@type, //@enum, //@field, //@variable, //@description.
Statements
Every statement ends with ;. Newlines are insignificant — multiple statements can appear on one line, and a single statement can span multiple lines:
let a = 1; let b = 2; let c = a + b; // multiple on one line
let result = longVariableName // split across lines
+ anotherLongVariable
- someOtherValue;Statements that end with a closing brace } (functions, if/for/while, etc.) do not take a trailing ;.
Basic Types
Primitive Types
| Type | Description | Examples |
|---|---|---|
int | Integer | 42, -123, +5 |
float | Floating-point number | 3.14, .5, 3., 1e-3 |
bool | Boolean | true, false |
String | Text | "hello", 'world' |
color | RGBA color | #FF0000, #FF000080 |
na | Missing/undefined value | na |
int and float
let a = 42;
let b = -123;
let d = 3.14;
let e = .14; // leading dot
let f = 3.; // trailing dot
let g = 314e-2; // 3.14String
Strings can use single or double quotes with identical semantics:
let a = "Hello, World!";
let b = 'Hello, World!';
let full = "Hello, " + "World!"; // concatenation with +Supported escape sequences:
| Escape | Meaning |
|---|---|
\\ | Backslash |
\n | Newline |
\r | Carriage return |
\t | Tab |
\" or "" | Double quote (in double-quoted strings) |
\' or '' | Single quote (in single-quoted strings) |
color
Color literals use hex notation with #:
#RRGGBB— 6 hex digits, fully opaque#RRGGBBAA— 8 hex digits, explicit alpha
let red = #FF0000; // fully opaque red
let semiRed = #FF000080; // semi-transparent redNamed color constants: color.RED, color.BLUE, color.GREEN, etc. Use color.new() for custom transparency.
na
na represents a missing or undefined value. It is compatible with any type but requires an explicit type annotation when used alone:
let a: float = na; // OK
let b = na; // ERROR: cannot infer type
if na(myValue) {
// handle missing value
}Operators
Arithmetic
let a = 10 + 3; // 13
let b = 10 - 3; // 7
let c = 10 * 3; // 30
let d = 10 / 3; // 3.333...
let e = 10 % 3; // 1Comparison
close > open; // greater than
close < open; // less than
close >= 100; // greater or equal
close <= 100; // less or equal
close == open; // equal
close != open; // not equalLogical
a and b; // AND
a or b; // OR
not a; // NOTTernary
let col = close > open ? color.GREEN : color.RED;Next Steps
- Variables & Qualifiers — type qualifiers, var/varip, na handling
- History Reference — accessing past bar values with
[] - Collections — array, map, matrix
- Control Structures — if, for, while, switch
- Functions & Methods — defining and calling functions

