Language
How ChartScript works: execution, types, variables, control flow, functions and libraries.
- Execution modelHow a script runs: once per bar from the oldest bar to the newest, again on every live update of the last bar, with history, rollback and the na rules.
- Series and qualifiersThe four qualifiers const, input, simple and series: what each means, why some arguments refuse a series value, and how to fix the errors.
- TypesThe value types of ChartScript (int, float, bool, color, string, drawing ids, collections), literals, na, conversions and how numbers behave.
- User types, enums and methodsDefine your own record types with fields and defaults, fixed sets of choices with enums, and methods you call with a dot.
- VariablesDeclaring variables with const and let, changing them with =, keeping values across bars with state and live state, tuples, scope and once blocks.
- OperatorsArithmetic, comparison, logical, nullish, ternary and history operators, int division, how na flows through them, line breaks and precedence.
- Conditionalsif, else if, else and switch in ChartScript, used as statements or as expressions that return a value, and what to keep out of them.
- Loopsfor, for…of over arrays and maps, the range loop, while, break and continue in ChartScript, loops as expressions, and the per-bar loop limits.
- FunctionsWriting your own functions with function or arrow syntax: parameters, defaults, named arguments, return, several results, per-call state, rules.
- CollectionsArrays, maps and matrices in ChartScript: creating them, keeping them across bars, the most useful functions, errors and size limits.
- Strings and formattingText in ChartScript: string literals, template literals, joining text, the str.* functions, and formatting numbers and times.
- Built-insA map of ChartScript's built-in namespaces and variables, with links to the reference, and how ta.* matches ChartDeck's own indicators bar for bar.
- LibrariesShare functions, types, enums and constants between your scripts with library(), export and import, and learn how versions and updates work.