Backtest a strategy
backtestExecute a strategy over historical data to generate performance metrics, trade list, and equity curve, along with model assumptions, for data-driven trading decisions.
Instructions
Runs a strategy over the history and returns metrics, the trade list and the equity curve. Signals fill at the next bar's open, costs are charged both sides, and a bar touching both stop and target counts as a stop. The assumptions come back with the result.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bars | No | How many of the most recent bars to use. | |
| symbol | Yes | Instrument symbol, for example XAUUSD. Case-insensitive. | |
| strategy | Yes | Strategy definition. | |
| timeframe | No | Bar size. Defaults to 1d. | |
| riskPercent | No | Equity risked per trade. Defaults to 1. | |
| slippageBps | No | ||
| commissionBps | No | ||
| stopAtrMultiple | No | ||
| targetRMultiple | No |