tradarascript-v2, emit bytecode the chart runtime executes.
What the checker validates
- Names for variables, user-defined functions, and built-in functions
int,float,bool,string,color,label,box,na, andseries<T>values- Arithmetic, comparison, boolean, unary, and ternary expressions.
if,?:,and,or, andnotaccept Pine-style truthy values (bool, numeric,na) - Assignments,
var/var float x = nadeclarations,:=reassignment, and[a, b] = exprtuple unpack - User functions, including indented bodies and tuple returns
- Indented
if/elseblocks - Ascending
forloops with constant bounds and at most 256 iterations - Positional and named function arguments, including drawing kwargs such as
bgcolor,border_color,text_color, andextend - 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]
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. Optionalgroupandinlinenamed 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
Example
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:Diagnostics
Each diagnostic includes:- Start and end line and column
- Severity
- Stable error code
- Message

