Backtesting
The process of testing a trading strategy on historical market data to evaluate how it would have performed before risking real capital.
See Backtesting in real trade signals
Tradewink uses backtesting as part of its AI signal pipeline. Get signals with full analysis — free to start.
Explained Simply
Backtesting lets you simulate a strategy against past market data — feeding the algorithm historical prices and seeing what trades it would have taken. A proper backtest accounts for transaction costs, slippage, and realistic fill assumptions. The key metrics to evaluate: total return, max drawdown, Sharpe ratio, win rate, and profit factor. However, backtests have limitations: past performance doesn't guarantee future results, and strategies can be overfit to historical data. A backtest is a necessary but not sufficient condition for live trading — walk-forward analysis and paper trading should follow before committing real capital.
Common Backtesting Mistakes
The most dangerous mistakes are look-ahead bias (using data that wouldn't have been available at trade time), survivorship bias (only testing on stocks that still exist today), and overfitting (tuning parameters to match historical noise rather than real patterns). Always use out-of-sample data for validation.
Key Backtesting Metrics and What They Mean
A backtest generates many numbers — knowing which to trust and which to be skeptical of separates professional quants from retail over-fitters.
Total return: The raw profit of the strategy over the backtest period. Meaningless without context — a 50% return over 10 years is mediocre; over 1 year is strong. Always compare against a benchmark (S&P 500 buy-and-hold).
Maximum drawdown (max DD): The largest peak-to-trough decline in equity during the backtest. This is the most important risk metric. A strategy with a 40% max drawdown may be psychologically impossible to trade live — most people abandon a system after a 20-25% drawdown regardless of long-term expectations.
Sharpe ratio: Excess return divided by standard deviation of returns. Measures return per unit of risk. Above 1.0 is acceptable; above 1.5 is good; above 2.0 is excellent. A Sharpe below 0.5 suggests the strategy barely compensates for its volatility.
Win rate vs. profit factor: Win rate alone is meaningless without knowing the average winner and loser size. A 40% win rate strategy can be highly profitable if winners average 3x the size of losers. Profit factor (gross profit / gross loss) above 1.5 is the minimum threshold for a viable strategy.
Number of trades: Statistical validity requires enough trades to distinguish signal from noise. Fewer than 100 trades produces unreliable statistics. Fewer than 30 is statistically meaningless. For high-frequency day trading strategies, aim for 500+ simulated trades minimum.
Backtesting Best Practices for Realistic Results
Avoiding common pitfalls requires deliberate methodology:
Model transaction costs realistically: Include commissions, exchange fees, and slippage. For stocks, model slippage as half the bid-ask spread plus market impact. For small-cap stocks or large orders, market impact can exceed the spread. Underestimating transaction costs is one of the most common reasons backtests look better than live trading.
Use adjusted price data: Historical prices must be adjusted for stock splits and dividends. Using unadjusted data creates phantom price jumps that appear as trading signals. Most data providers (Polygon.io, Yahoo Finance) provide adjusted close prices — verify before backtesting.
Simulate realistic execution: Assume fills at the open or next bar after signal generation — not on the same bar (which would require predicting the close). Assuming you fill at the signal bar's close is a form of look-ahead bias.
Apply position sizing consistently: Backtest with the same position sizing rules you intend to use live. Fixed fractional (risk 1% per trade) produces very different equity curves than fixed dollar amounts. The position sizing model has a larger impact on outcomes than most traders realize.
Out-of-sample testing: Reserve a portion of historical data (20-30%) that the strategy never sees during optimization. Only test the final, locked strategy parameters on this out-of-sample period. If performance degrades significantly on out-of-sample data, the strategy is overfit.
Cross-market validation: Test the strategy on different markets, asset classes, or timeframes. A momentum strategy that works on US large-cap stocks should also work (to some degree) on European stocks, ETFs, or even commodities. Strategies that only work on a narrow slice of history and assets are likely overfit.
Understanding Backtest Limitations
Backtests are approximations of reality, not reality itself. Several structural limitations always exist:
Market impact is underestimated: A backtest assumes you can buy and sell at modeled prices without moving the market. In reality, large positions in illiquid stocks move prices against you. The more capital you trade and the less liquid the market, the worse this becomes.
Regime non-stationarity: A strategy optimized on 2010-2020 data includes the longest bull market in history. That regime may not recur. Backtests trained on a single regime often fail when conditions change — low-volatility strategies from 2017 collapsed in 2018 and 2022.
Data quality issues: Incorrect historical prices (due to data vendor errors, unadjusted splits, erroneous ticks) create phantom profits in backtests. Always validate historical data from multiple sources before trusting results.
Psychology and execution risk: Backtests assume perfect execution and no psychological interference. In live trading, you hesitate on entries, move stops, take profits early, and make dozens of discretionary deviations that erode returns. The gap between backtested and live returns is partly a discipline and execution gap, not just a statistical one.
How to Use Backtesting
- 1
Define Your Strategy Rules Precisely
Write down exact entry criteria, exit criteria, position sizing, and stop-loss rules with no ambiguity. For example: 'Buy when 9 EMA crosses above 21 EMA and RSI is above 50. Set stop at 2x ATR below entry. Take profit at 3x ATR above entry. Risk 1% per trade.' Every rule must be programmable.
- 2
Gather Clean Historical Data
Use adjusted data that accounts for splits, dividends, and delistings. Survivorship bias (only testing on stocks that exist today) will inflate results. Use data going back at least 5 years covering multiple market regimes (bull, bear, choppy).
- 3
Run the Backtest
Use a backtesting platform (QuantConnect, Backtrader, or a spreadsheet for simple strategies). Execute the strategy against historical data bar-by-bar. Include realistic transaction costs ($0.005/share + spread), slippage (1 tick per trade), and commission.
- 4
Evaluate Results with Key Metrics
Check: total return, Sharpe ratio, max drawdown, win rate, profit factor, and number of trades. A good strategy has Sharpe >1.0, max drawdown <25%, profit factor >1.5, and 100+ trades for statistical significance.
- 5
Validate with Out-of-Sample Testing
Split your data: train on 70% (in-sample), test on 30% (out-of-sample). If the strategy performs well on the in-sample but poorly on the out-of-sample, it's overfit. Only deploy strategies that maintain performance on data the model never saw during development.
Frequently Asked Questions
How long should a backtest period be?
At minimum, a backtest should cover multiple market regimes — at least one bull market, one bear market, and one ranging/choppy period. For day trading strategies, 2-3 years of minute data typically provides enough trades for statistical significance (1,000+ simulated trades).
Can a profitable backtest still lose money in live trading?
Yes. Slippage, market impact, changing market conditions, and overfitting can all cause live results to underperform backtest results. A common rule of thumb: expect live performance to be 30-50% worse than backtested performance.
What is the difference between in-sample and out-of-sample backtesting?
In-sample data is the historical period used to develop and optimize the strategy parameters. Out-of-sample data is a separate period the strategy has never seen during development. A strategy that performs well in-sample but poorly out-of-sample is overfit to historical noise rather than capturing a real market edge. Out-of-sample testing is the minimum bar for believing a strategy has genuine predictive value.
What is a good Sharpe ratio for a backtested trading strategy?
A Sharpe ratio above 1.0 is generally considered the minimum threshold for a viable strategy. Ratios of 1.5-2.0 are considered strong, and above 2.0 is excellent for a live-tradeable strategy. However, treat very high Sharpe ratios (above 3.0) in backtests with skepticism — they often indicate overfitting or unrealistic transaction cost assumptions. The live Sharpe ratio almost always falls 30-50% below the backtested Sharpe after accounting for real-world execution.
How do you account for survivorship bias in backtesting?
Survivorship bias occurs when you test only on stocks that currently exist, excluding companies that went bankrupt, were delisted, or merged during the backtest period. To correct for it, use a point-in-time constituent database that includes all stocks that were in the market during each historical period, including delisted ones. S&P 500 constituent databases maintained at specific historical dates are available from data providers like CRSP, Compustat, and Sharadar. Ignoring survivorship bias artificially inflates returns in strategies that screen for certain financial characteristics.
How Tradewink Uses Backtesting
Tradewink's Backtester class runs full walk-forward backtests on every intraday strategy (ORB, VWAP reversion, momentum breakout) using historical minute-bar data. The system tracks MFE/MAE, regime-adjusted returns, and statistical significance. Strategy health monitoring continuously compares live performance against backtested expectations — if a strategy drifts beyond two standard deviations, it's automatically flagged for review.
Trading Insights Newsletter
Weekly deep-dives on strategy, signals, and market structure — written for active traders. No spam, unsubscribe anytime.
Related Terms
Learn More
Momentum Trading: Complete Strategy Guide for Breakout Stocks
Complete momentum trading strategy guide. Learn how momentum trading works, how to find breakout stocks, time entries with volume confirmation, manage risk, and automate momentum strategies with AI.
Mean Reversion Trading Strategy vs. Momentum: When to Use Each
A practical comparison of mean reversion and momentum trading. Learn when each strategy works, how market regime changes the edge, and how Tradewink adapts in real time.
How AI Day Trading Bots Actually Work: The 8-Stage Pipeline from Data to Execution
A builder's breakdown of a production AI day trading system. Covers the full pipeline: market data ingestion, regime detection, screening, AI conviction scoring, position sizing, execution, dynamic exits, and self-improvement.
Previous
Cup and Handle
Next
Walk-Forward Analysis
See Backtesting in real trade signals
Tradewink uses backtesting as part of its AI signal pipeline. Get daily trade ideas with full analysis — free to start.