Type/to search
Getting Started
Platform Basics
Writing Strategies
Development Tools
Backtesting System
Overview and Starting a Backtest
Backtest Modes and Order Matching
Backtest Configuration and Saving
Supported Languages and Exchanges
Reading Backtest Results
Parameter Optimization
Custom Data Source
Local Backtesting Engine
Backtest Page Shortcuts
Advanced Topics
Data and Research
Extended API Interface

The backtest configuration on the "Backtest" tab (time range, exchanges, fees, ...) and the strategy parameters can be saved with the strategy and are loaded again the next time the strategy is opened.

Saving

  • Click "Save Backtest Settings": the configuration and strategy parameters are written as a comment block (the backtest block) at the top of the strategy source.
  • Click "Save Strategy": the platform also records the current backtest configuration and strategy parameters.

Loading

  • When the strategy editor is opened or refreshed, the configuration in the source's backtest block is loaded first.
  • If the source has no backtest block, the configuration recorded by the last "Save Strategy" is loaded.
  • After editing the backtest block by hand, click the "Backtest Settings" button above the block to apply the change to the backtest form.

Block format

The word backtest follows the language's block-comment opener directly, then one key: value per line:

javascript
/*backtest start: 2024-01-01 00:00:00 end: 2024-03-01 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Binance","currency":"BTC_USDT","balance":10000,"stocks":0,"fee":[0.1,0.1]}] args: [["fast",5],["slow",20]] */

Comment syntax per language: JavaScript, Rust and PINE use /*backtest ... */; Python uses '''backtest ... '''; MyLanguage uses (*backtest ... *).

KeyFormatDescription
start, endYYYY-MM-DD HH:mm:ssStart and end time, parsed in the browser's time zone.
period1m, 1h, 1d etc., or secondsStrategy K-line period.
basePeriodsameBase K-line period; defaults to period; ignored in real-tick mode.
mode1Real-tick mode; omit for simulated-tick mode.
exchangesJSON arrayOne element per exchange object, fields below.
argsJSON arrayStrategy parameters [["name", value], ...]; ["name", value, templateId] sets a template's parameter.

Fields of an exchanges element; everything except eid and currency is optional:

FieldDescription
eidExchange ID, e.g. Binance, Futures_OKX.
currencyTrading pair, e.g. BTC_USDT.
balance, stocksInitial quote-currency and base-currency balances.
fee[maker rate, taker rate] in percent.
feeMinMinimum fee per fill; only applies to some markets.
depthDeep, depthAmountDepth levels and the amount on each simulated level.
tradesModeWhether trade prints are replayed in real-tick mode: "0" replay, "1" do not.
feederCustom data source URL, see Custom Data Source.

The other options of the backtest form (slippage, network delay, failure probability, max K-line bars, etc.) are not written into the comment block; they are stored with the strategy record when you "Save Strategy". The local backtest engines also read this block, but only some of its keys, see Local Backtesting Engine.