Historical Backtesting
Test trading strategies over historical data and validate performance metrics.
Backtesting Overview
Backtesting allows you to simulate how a trading strategy would have performed using historical market data. By running a strategy over historical periods, you can analyze performance metrics, drawdown characteristics, and execution behaviors before deploying capital.
The platform supports historical backtesting for key strategies including:
- GoldenCross: A simple moving average crossover.
- EMACross: An exponential moving average crossover.
- RSI: An RSI hook entry logic with EMA-50 confirmation.
- MACD: A MACD signal line crossover.
- BollingerBands: A mean reversion strategy based on statistical bands.
- Momentum: A short-lookback momentum strategy.
- Scalping: A high-frequency strategy with tight stops and quick targets.
- MTF: A multi-timeframe strategy combining daily, 4-hour, and 1-hour indicators.
- Variants A-D: Advanced strategy rules combining technical indicators and Fibonacci retracements.
Performance Metrics
When a backtest completes, the system provides several key metrics:
| Metric | Description |
|---|---|
| Total Return | The cumulative percentage gain or loss over the test period. |
| Annualized Return | The geometric progression rate that measures return on an annual basis. |
| Sharpe Ratio | A measure of risk-adjusted return, indicating excess return per unit of volatility. |
| Sortino Ratio | Similar to Sharpe, but only penalizes negative volatility (downside risk). |
| Max Drawdown | The largest peak-to-trough decline in capital during the test period. |
| Profit Factor | The ratio of gross profits to gross losses. |
| Win Rate | The percentage of trades that closed in profit. |
| expectancy_r | The average R-multiple (risk unit) expectation per trade. |
| SQN | System Quality Number (Van Tharp SQN) measuring system reliability. |
Walk-Forward Validation
To prevent optimization bias (overfitting), the platform provides Walk-Forward Validation. This process splits your historical dataset into:
- In-Sample Window (Training): The strategy parameters are optimized to fit the historical data.
- Out-of-Sample Window (Testing): The optimized parameters are evaluated unmodified on untouched data.
This split helps verify whether the strategy’s edge is robust or simply fit to historical noise. The validation returns a kill_criterion status based on the out-of-sample System Quality Number (SQN):
- Kill: If the out-of-sample SQN is below 1.6, the strategy’s edge is indistinguishable from random market noise.
- Insufficient Sample: If the backtest results in fewer than 30 trades, the sample size is too small to draw a statistically significant conclusion.
Comparing Backtests and Live Behavior
While backtesting is a valuable diagnostic tool, it is critical to understand its limitations:
What Backtesting Cannot Tell You
- Past Performance is Not Predictive: Market conditions shift. A strategy that performed exceptionally well during a trending period may fail during a range-bound market.
- Overfitting Risk: It is easy to tweak parameters until a backtest looks perfect. This is curve-fitting, and it frequently results in poor performance in live markets because the settings are optimized for past noise rather than structural edges.
- Execution Mismatches: Backtests assume perfect execution. In live environments, your results will differ due to factors not fully modeled in basic tests:
- Slippage: The difference between the expected execution price and the actual fill price.
- Spread: The difference between the buy and sell prices.
- Latency: Delay in signal delivery or broker order routing.
- Fill Quality: Partial fills or rejections on large orders.
Scorecard Comparison
The platform provides a live vs. backtest scorecard. This scorecard compares the live shadow-mode performance of a strategy with its historical backtest record over the same timeframe.
The win_rate_drift_pct metric measures the difference between the live win rate and the backtest win rate. A significant negative drift indicates that the strategy edge is being degraded by live execution costs (such as spreads and slippage) rather than flawed logical rules.