Education

How to Backtest a Trading Strategy — The Right Way

Backtesting is the process of testing a trading strategy against historical data to see how it would have performed. Done right, it gives you confidence before risking real money. Done wrong, it gives you false confidence — which is worse than no testing at all.

Why Backtesting Matters

Would you invest in a business without seeing its financial history? Trading is the same. A backtest is your strategy's financial history — simulated, but based on real market data.

Step-by-Step Backtesting Process

Step 1: Define Your Rules

Write down exact entry and exit rules. "Buy when the trend looks good" is not a rule. "Buy when the 6-period SMA of the open crosses above the 20-period SMA" is a rule.

Your rules should be 100% objective — a computer should be able to follow them without interpretation.

Step 2: Choose Your Data

Get historical price data for the market you want to trade. More data is better — at least 2 years, ideally 5+. Make sure the data includes different market regimes: trending, ranging, volatile, and calm.

Data sources: TradingView, ThinkorSwim, Yahoo Finance, Quandl, or your broker's platform.

Step 3: Split Your Data

This is critical. Divide your data into two periods:

If your strategy works on both periods, it's more likely to work in live trading.

Step 4: Run the Backtest

Apply your rules to the in-sample data. Record every trade: entry, exit, P&L, duration. Calculate key metrics: win rate, profit factor, max drawdown, expectancy.

Step 5: Validate Out-of-Sample

Run the exact same rules on the out-of-sample data without changing anything. If the results are similar to in-sample, your strategy is robust. If they fall apart, you've overfit.

Step 6: Monte Carlo Simulation

Randomize the order of your trades 10,000 times. This shows you the range of possible outcomes — not just the one sequence that happened historically. Use the 95th percentile drawdown for position sizing.

Step 7: Forward Test (Paper Trade)

Run the strategy in real-time on a demo account for at least 2-4 weeks. This catches issues that backtests miss: slippage, execution delays, and platform differences.

The #1 Backtesting Mistake: Curve Fitting

Curve fitting is when you optimize a strategy until it looks perfect on historical data — but it only works on that specific data. It's the most common and most dangerous mistake in algo trading.

Signs of curve fitting:

How to Avoid Curve Fitting

Key Metrics to Evaluate

Backtesting Platforms

From Backtest to Live: What Changes

Your live results will be worse than your backtest. Always. Here's why:

Rule of thumb: Expect live results to be 20-40% worse than backtested results. If your backtest is barely profitable, your live trading will likely lose money.

See a Backtested Strategy Running Live

11,949 backtested trades across 4 futures markets. Same algorithms now running live with every trade logged.

View Live Results →

7-day free trial · No credit card required

Trading involves substantial risk of loss. Past performance — backtested or live — is not indicative of future results. This is educational content, not financial advice.