Backtesting
Backtesting is the process of running a strategy against historical market data to understand how it would have behaved under defined assumptions.
Backtesting is not a guarantee of live performance. It is a research workflow that helps traders find bugs, test assumptions, compare versions, and decide whether a system deserves more validation.
Why Backtesting Matters
A strategy should not go from idea to live trading without evidence.
Backtesting helps answer:
- Did the logic do what the trader expected?
- Did it enter and exit at the correct times?
- Did it overtrade?
- Did it survive different market regimes?
- Was profit concentrated in one short period?
- Did drawdown exceed acceptable limits?
- How sensitive is the strategy to parameter changes?
- How much do fees and slippage change the result?
Backtesting should also help detect fragile results. A high-profit result is less valuable if it only works at one exact parameter setting. HyperionX's optimization workflow can use concepts such as the closely guarded island penalty to penalize isolated winners and reward stable strategy behavior.
Required Inputs
A useful backtest needs:
- Instrument.
- Data series type and value.
- Historical date range.
- Strategy script.
- Strategy parameters.
- Initial account value.
- Commission model.
- Slippage/fill assumptions.
- Position sizing model.
- Session/trading hours assumptions where applicable.
Backtest Workflow
Recommended flow:
- Build the strategy in Code Lab.
- Compile with zero errors.
- Load the strategy into the validation/backtest window.
- Select instrument and timeframe.
- Select historical range.
- Configure account, commission, and size assumptions.
- Run the backtest.
- Review trades and performance metrics.
- Fix logic issues.
- Re-test on out-of-sample data.
- Move to playback or simulation before live trading.
Important Metrics
Review more than net profit.
Useful metrics include:
- Net profit.
- Gross profit.
- Gross loss.
- Max drawdown.
- Profit factor.
- Sharpe ratio.
- Trade count.
- Win rate.
- Average win.
- Average loss.
- Largest win.
- Largest loss.
- Average trade.
- Consecutive winners and losers.
- Time in market.
- Exposure by instrument.
Backtest Assumptions
Every backtest contains assumptions. Document them.
Common assumptions:
- Candles are complete and accurate.
- Intrabar price movement is approximated.
- Fills happen at expected prices.
- Slippage is fixed or ignored.
- Commissions are accurate.
- Liquidity is sufficient.
- Order size would not move the market.
- Provider data has no gaps.
The closer the strategy is to high-frequency or intrabar logic, the more important fill modeling and data quality become.
Historical, Playback, Simulation, Live
HyperionX should support a staged validation model:
| Stage | Purpose |
|---|---|
| Historical backtest | Fast research on historical candles. |
| Playback | Replays historical sessions to test real-time behavior. |
| Simulation | Tests live platform behavior without risking capital. |
| Small live | Tests real execution with controlled risk. |
| Scaled live | Increased size only after stability and risk controls are proven. |
AI In Backtesting
AI can help review results, but it should not be the final decision maker.
Useful AI tasks:
- Explain a performance report.
- Identify suspicious parameter overfitting.
- Summarize drawdown periods.
- Compare two strategy versions.
- Suggest validation tests.
- Review Code Lab logic for obvious mistakes.
AI should not automatically choose live parameters or submit live trades without explicit tools, permissions, and user confirmation.