Run a backtest
The app runs a backtest on a strategy you saved.
Details#
Backtest one saved BullScript™ strategy on one market, on the same engine as the Backtests tab of the member's chart, and save the run there (marked AI). The script must be a strategy: it starts with strategy() and trades with strategy.entry, strategy.order, strategy.exit or strategy.close; an indicator is refused with backtest_not_strategy. Write and save it with save_script first. Its strategy() line sets the position size, commission and slippage; when it sets no commission or slippage, Bullmania's defaults apply per side: crypto 0.10% fee, 0.05% spread and 0.05% slippage; US stocks and ETFs 0% fee, 0.02% spread and 0.02% slippage. Orders fill at the next bar's open, only closed bars are used, and process_orders_on_close, calc_on_every_tick and same-bar fills are always off (settings.forced_off lists what the script asked for and did not get). Runs on 1D and 1W, on crypto spot markets and US stocks and ETFs. Without from and to it tests all the history the market has. Omit symbol to use the market on the member's chart. The answer has strategy and just_holding side by side for the same dates and costs (profit_pct; worst_drop_pct, the largest fall from a high as a positive number; cagr_pct), comparison (one sentence to pass on), stats (trades, win_rate_pct, profit_factor, fees_pct, exposure_pct, sharpe and more), settings, warnings ({ code, message }, plain sentences), the 10 most recent trades with trades_total, link (this run in the member's Backtests tab), disclaimer and report_to_member. Report the comparison with just holding, every warning, the number of trades and the disclaimer every time; results are hypothetical, never money the member would have made. Traps: trying many variations and keeping the best fits the past, not the future (overfitting), so change one thing at a time and tell the member how many versions you tried; fewer than about 30 trades can be luck; a script that reads a higher timeframe's unfinished bar or the future (lookahead), or an indicator that changes its past values such as pivots or zigzag, looks better than it could trade (warnings flag it); never remove costs to improve a result; a market that is listed today is one that survived (survivorship bias): coins and companies that failed are not in any test, so past results flatter every strategy. A compile or runtime error returns error_detail; fix the script with save_script and run again. Counts as one connector call; backtests also have an hourly limit of their own (backtest_limit, with retry_after). Example: script <id from list_scripts>, symbol BTC/USDT, venue BINANCE, timeframe 1D.
Inputs#
| Name | Type | Required | Description |
|---|---|---|---|
| script | string | Required | Required. The id of a saved BullScript™ strategy the member can run: their own from list_scripts or save_script, or an invite-only or Community one from list_indicators (script:<id> also works). |
| symbol | string | Optional | Optional. Ticker or pair, for example BTCUSDT or AAPL. Omit to use the market on the member's chart. |
| venue | string | Optional | Optional venue, for example BINANCE, COINBASE, BITSTAMP or NASDAQ. BINANCE is Binance spot, not Binance futures. |
| timeframe | 1D | 1W | Optional | Optional. 1D or 1W. Omit for 1D. |
| from | string | Optional | Optional. First UTC date to test, YYYY-MM-DD, for example 2021-01-01. Omit to start at the market's first bar. |
| to | string | Optional | Optional. Last UTC date to test, YYYY-MM-DD. Omit to end at the last closed bar. |
| layout | string | Optional | Layout name from list_layouts, or "Default" (the member's own chart). Omit to use the layout the member has open, or Default when no chart is open. |