Skip to main content
TradaraScript has a compiler that can check source and, for tradarascript-v2, emit bytecode the chart runtime executes.
tradarascript-v1 still selects one registered native indicator family. Passing the compiler-front-end check on v1 source does not execute that formula. //@version=tradarascript-v2 (or language_version: tradarascript-v2) compiles to a VM bundle and streams script.output.v2 plots, shapes, labels, and boxes. It is not full Pine: no lines/tables/polylines, request.security, alerts, or broker orders.

What the checker validates

  • Names for variables, user-defined functions, and built-in functions
  • int, float, bool, string, color, label, box, na, and series<T> values
  • Arithmetic, comparison, boolean, unary, and ternary expressions. if, ?:, and, or, and not accept Pine-style truthy values (bool, numeric, na)
  • Assignments, var / var float x = na declarations, := reassignment, and [a, b] = expr tuple unpack
  • User functions, including indented bodies and tuple returns
  • Indented if / else blocks
  • Ascending for loops with constant bounds and at most 256 iterations
  • Positional and named function arguments, including drawing kwargs such as bgcolor, border_color, text_color, and extend
  • Hex color literals (#rgb, #rrggbb, #rrggbbaa) anywhere a color is expected
  • Input, plot, plotshape, label, and box declarations
  • Constant, non-negative history offsets such as close[1]
The checker recognizes bar_index and the bar series open, high, low, close, and volume. A scalar combined with a series produces a series result. It also recognizes these constants: color.red, color.green, color.blue, color.white, color.black, color.orange, color.yellow, color.purple, shape.* (circle, cross, xcross, triangleup, triangledown, arrowup, arrowdown, square, diamond, labelup, labeldown, flag), location.* (abovebar, belowbar, top, bottom), size.* (tiny through huge), xloc.bar_index, yloc.price, and label.style_*. Anything else in those namespaces — location.absolute, for instance — is an unknown identifier.

Checked functions

The first compiler manifest includes:
  • Inputs: input.int, input.float, input.bool, input.string, input.session, input.color. Optional group and inline named args layout the indicator settings form.
  • Math: math.abs, math.min, math.max, math.pow, math.sqrt, math.round, math.ceil, math.floor
  • Text and colors: str.tostring, color.new
  • Technical analysis: ta.sma, ta.ema, ta.rma, ta.wma, ta.stdev, ta.atr, ta.rsi, ta.change, ta.mom, ta.roc, ta.highest, ta.lowest, ta.crossover, ta.crossunder
  • Declarations: study, plot, plotshape
  • Drawings: label.new, box.new, their supported setters, and deletion
This manifest drives function signatures and examples. A function not listed there produces an unknown-function diagnostic.

Example

The checker accepts the composed expression and infers spread as series<float>. Save the same source with //@version=tradarascript-v2 to execute that composition on the chart. v1 save still maps to one native family. The CLI also emits bytecode:
POST /v1/scripts/compile with language_version: "tradarascript-v2" stores that bundle. v1 compile remains kind inference.

History rules

History offsets must be constant integers from 0 through 511:
The checker rejects dynamic and negative offsets:
Index named series. Assign a computed expression before indexing it:
Bounded offsets let the VM allocate deterministic series buffers and enforce memory limits before execution.

Diagnostics

Each diagnostic includes:
  • Start and end line and column
  • Severity
  • Stable error code
  • Message
The checker also reports inferred inputs, plots, and the maximum history lookback. Script Studio does not render these diagnostics as editor squiggles yet.