Appearance
Backtesting Service
The backtesting service loads historical candles for a symbol and time range, compiles the script, and runs it over the full window. It returns candles, chart outputs, and, for strategy scripts, trade and performance reports.
What it does
- Load candles for
[fromTime, toTime]from the configured candle source. - Compile the script. Both indicator and strategy scripts are supported.
- Execute the script over the loaded window.
- Return candles, per-bar calculation results, and strategy analytics when applicable.
Unlike the validator, backtesting returns every bar in the calculation result, not just first-bar samples.
Typical use cases
- Evaluate a strategy over a historical period.
- Produce equity curves, trade lists, and performance summaries.
- Render full-window indicator outputs alongside candle data.
- Compare strategy return against buy-and-hold.
Script types
Both indicator and strategy scripts are supported. Strategy scripts must declare strategy() in the init section. See the Strategy reference for order simulation semantics.
Strategy response extras
When the script is a strategy, the response may include:
| Field | Description |
|---|---|
strategyTradeReport | Closed and open trades with PnL, drawdown, and signal names |
strategyFillReport | Individual entry and exit fills per bar |
strategyOrderReport | Resting orders and how each ended, plus any market order the account could not fund |
strategyAnalytics | Equity series, performance summary, Sharpe/Sortino ratios, and related metrics |
Indicator-only scripts omit these fields but still return calculationResult with per-bar output, spline, shape, backgroundColor, and barColor channels.
Request constraints
langmust bedxscript-js.fromTimeandtoTimeare required;fromTimemust be before or equal totoTime.symbolmust be a valid dxFeed candle symbol (e.g.AAPL{=d}for daily candles).
On candle fetch failure, the response contains an error and an empty candle list. On script failure after candles are loaded, candles are still returned alongside the error.
API
See Backtest RPC for the HTTP endpoint, request body, and response schema. Strategy scripts use the strategy() language API; backtest responses include strategyTradeReport, strategyFillReport, strategyOrderReport, and strategyAnalytics defined there.