The Scripting Language for Automated Trading
Write trading bots in JavaScript-like syntax. Backtest strategies on historical data, forward test with paper trading, and deploy live — one script, three modes. Combines the best of Pine Script, MQL5, and pandas.
What is QuantScript?
QuantScript is a scripting language designed for automated trading. It lets you write quantitative trading strategies using familiar JavaScript syntax, then backtest them on historical data, forward test with simulated brokers, and deploy them as live trading bots — all from the same script.
QuantScript includes 50+ built-in technical indicators (SMA, RSI, MACD, Bollinger Bands, Supertrend, and more), a unified trading API inspired by CCXT for broker-portable execution, and built-in risk management with stop-loss, take-profit, and position limits. Whether you’re building a forex expert advisor, a crypto trading bot, or backtesting a trend-following strategy, QuantScript handles the full lifecycle from idea to live execution.
Try it now in your browser at quantscript.com — no installation required.
Quick Start
Write a complete SMA crossover strategy in just a few lines.
candles(symbol: "BTCUSD", resolution_type: "1h", bars: 500);
mode(mode_type: "backtest", script_name: "SMA Crossover");
broker(adapter: "sim", config: { initial_capital: 100000 });
let fastSMA = ta.sma(candle.close, 10);
let slowSMA = ta.sma(candle.close, 30);
event.onCandle((candle) => {
if (ta.crossover(fastSMA, slowSMA)) {
trade.orderSend({ side: "buy", qty: 1 });
}
if (ta.crossunder(fastSMA, slowSMA)) {
trade.closePosition({});
}
});
Why QuantScript?
Purpose-built for quantitative finance with familiar JavaScript syntax.
JavaScript Syntax
Standard let, const, if, for, arrow functions, destructuring. Only one custom keyword: mode.
DataFrame Primitive
Named, aligned time-series columns — like pandas, but native to the language.
Built-in TA
ta.sma(), ta.rsi(), ta.bbands(), ta.crossover(), and 50+ more indicators — including MACD, Stochastic, ATR, Supertrend, ADX, and OBV.
Strategy Execution
trade.orderSend(), trade.closePosition() for all modes. CCXT-style broker-portable trading with trade.createOrder(), trade.positions(), trade.account().
Event-Driven
event.onCandle(), event.onNewCandle(), event.onTick() — plus trade lifecycle events: onFill(), onReject(), onPositionOpened().
Declarative Config
candles(), broker(), risk(), mode() — orthogonal declarations that answer specific questions. No monolithic config objects.
CLI + Playground
Run scripts headlessly, replay historical data, or launch a browser-based interactive playground.
Virtual Trading Accounts
Run multiple strategies on one broker account with isolated capital, equity, and risk limits per strategy. Set allocated_capital in broker() config.
Built-in Namespaces
Rich standard library for technical analysis, math, data, and trading.
ta.*Technical analysis
ta.sma(), ta.ema(), ta.rsi(), ta.bbands(), ta.crossover(), ta.macd()Math.*Math functions
Math.abs(), Math.sqrt(), Math.pow(), Math.round(), Math.sin(), Math.log()Array methodsJavaScript-style array operations
arr.push(), arr.sort(), arr.slice(), arr.includes(), arr.join(), arr.lengthString methodsJavaScript-style string operations
"hello".includes(), .split(), .replace(), .toUpperCase(), .format(), .lengthtrade.*Order execution & introspection
trade.buy(), trade.sell(), trade.createOrder(), trade.closePosition(), trade.positions(), trade.orders(), trade.fills(), trade.account()risk.*Risk management
risk.trade.maxOrderQty(), risk.portfolio.maxDrawdown(), risk.portfolio.dailyLossLimit(), risk.protection.maxDailyOrders(), risk.protection.killSwitch()strategy.*Strategy introspection
strategy.position_size, strategy.equity, strategy.netprofit, strategy.opentrades, strategy.closedtrades, strategy.wintradeschart.*Chart plotting
chart.plot(), chart.plotshape(), chart.hline(), chart.bgcolor(), chart.fill(), chart.pane()event.*Event callbacks
event.onCandle(), event.onNewCandle(), event.onTick(), event.onTimer(), event.onFill(), event.onReject(), event.onPositionOpened()input.*User parameters
input.int(), input.float(), input.bool(), input.string()Execution Modes
Built-in runtime guardrails that prevent accidental real trades during testing. Set via mode() declaration.
Simulate trades on historical data with configurable execution strategies (bar-match-netting, crypto-spot, us-equities, and more).
Forward-test with a simulated broker. Same runtime as live, but no real orders are placed.
Real execution via broker connection with risk guardrails, preflight validation, automatic position reconciliation, and virtual trading accounts for multi-strategy capital isolation.