TypeScript
TypeScript is not a separate language option. Create the strategy as JavaScript and add a // @ts-check line to the code (or click the "TypeScript" button at the top right of the editor); the platform then treats it as TypeScript and compiles it to JavaScript before backtesting or live trading. When a strategy is saved through the AI/MCP tools, the language can be given as typescript: the platform saves it as a JavaScript strategy and adds //@ts-check at the top automatically (see External Interfaces → AI Access).
Static type checking catches mistakes such as wrong argument counts, property names or types while you write, and makes editor completion more accurate.
A minimal example:
ts
// @ts-check
interface Signal {
side: "buy" | "sell"
price: number
}
function getSignal(ticker: ITicker, ma: number): Signal | null {
if (ticker.Last > ma) {
return {side: "buy", price: ticker.Last}
}
if (ticker.Last < ma) {
return {side: "sell", price: ticker.Last}
}
return null
}
function main() {
while (true) {
const records = exchange.GetRecords()
const ticker = exchange.GetTicker()
if (records && ticker && records.length > 20) {
const ma = TA.MA(records, 20)
const signal = getSignal(ticker, ma[ma.length - 1])
if (signal) {
Log(signal.side, signal.price)
}
}
Sleep(60 * 1000)
}
}
Type declarations for the platform API are built into the strategy editor; nothing needs to be referenced in the code. They cover the global functions, the exchange object, data structure interfaces such as ITicker, IRecord, IOrder and IPosition, and TA, talib and so on. Language features, APIs and libraries at run time are the same as for JavaScript strategies (see Programming Languages → JavaScript).