Learn QuantScript by example. Each example includes complete, runnable code. Copy and run with the CLI.
| Example | Description |
|---|---|
| Language Basics | Variables, data types, strings, arithmetic, control flow, arrays, objects, functions, math, and utilities. |
| SMA Trend + RSI Indicator | Indicator-mode script that overlays fast/slow SMA on price chart with RSI oscillator in a separate pane. No trading logic. |
| SMA Trend Pullback Backtest | Backtests a trend-following strategy on XAUUSD 1H candles. 50-SMA defines trend, RSI(14) identifies pullback entries, ATR-based stop loss and take profit. |
| SMA Crossover + RSI Filter — Paper Trading | Forward-test a trend strategy with simulated broker. SMA(10)/SMA(20) crossover defines trend, RSI(14) filters entries. Same runtime as live, no real orders. |
| Mean Reversion Grid System — EURUSD Live | Symmetric grid around Bollinger Band midline. Grid spacing adapts to EURUSD 1-minute volatility. Buys at grid dips, sells at mean reversion targets with stop-loss. |
| Multi-Timeframe Indicator | BTCUSD 1h chart with ETH 4h SMA overlay computed on native bars using data.loadCandles() with a callback. Includes historical lookback. |
| Multi-Asset Dashboard | BTC 1h chart with ETH 4h SMA and XAU daily RSI signal — multiple data.loadCandles() calls evaluating indicators on different symbols and timeframes. |
| Cross-Timeframe Trend Strategy — Paper Trading | Daily SMA trend filter with 15m RSI entries. Uses data.loadCandles() for cross-timeframe analysis in a paper trading strategy with trade.buy/sell. |