Functions, types, enums and lists
Simple on top, a full language underneath.
type Level:price: pricetouched: int = 0formed_at: timeenum Regime: trending, ranging, volatilefn swing_strength(len: int) -> number:up = highest(high, len) - closedown = close - lowest(low, len)return (down - up) / atr(14)action fn enter_long(size_risk: percent = 1%) -> bool:buy risk: size_risk, stop: 20 pips, target: 2Rreturn truefndefines a pure function. It calculates and returns a value.action fnmay place orders, so it can only be called where orders are allowed. A plainfnthat tries to trade is an error (AS0403).typedefines a record with named, typed fields and optional defaults.enumdefines a fixed set of names.- Parameters can have types and defaults:
fn f(source: series<number> = close, length: int = 20) -> number.
Lists and lambdas
levels.push(Level(price: high, formed_at: time))levels = levels.filter(l => l.touched == 0).keep_last(50)ranked = levels.sort_by((a, b) => a.price - b.price)Lists support push, pop, remove, filter, map, sort_by, keep_last, first, last, len and contains, plus the aggregates sum, mean, min and max. A lambda is written x => expression.