Backtesting

How to Backtest Your Trading Strategy: The Complete Guide

Quick Answer

Backtesting means running your strategy on past price data to see if it would have been profitable. The steps: (1) Define your setup rules exactly, (2) Run on 100+ trades of historical data, (3) Calculate expectancy, (4) Check for curve-fitting (your setup only works on that data?), (5) Forward test on new data. Backtesting is the cheapest way to validate a strategy before risking real money.

Key Takeaways
  • Backtesting is mandatory before live trading
  • Most traders backtest poorly (cherry-picking data, ignoring commissions, curve-fitting)
  • The backtest must survive out-of-sample testing
  • Backtesting shows risk, not reward; use position sizing to manage it

Backtesting is how you validate a strategy before risking real money.

The backtesting process

Step 1: Define your setup rules precisely

NOT: "Buy breakouts"

INSTEAD:

This is testable. You can code it or backtest manually.

Step 2: Gather historical data

Use a charting platform, a data provider, or a backtesting engine.

Options:

For S&P 500 or SPY, data is free and clean.

Step 3: Run 100+ trades

Manually or with software, run your setup on the past 100 trades.

Record:

After 100 trades:

Step 4: Validate the backtest

Red flags (bad data):

Green flags (realistic data):

Step 5: Check for curve-fitting

Curve-fitting: Your setup works only on the data you tested, not on new data.

Test for it:

  1. Split your data: 60 trades in-sample, 40 trades out-of-sample
  2. Backtest on the 60 trades
  3. Run the same setup on the 40 untested trades
  4. Do results match?

If in-sample expectancy is +0.2R and out-of-sample is −0.1R, your setup is curve-fit. Don't trade it.

If both are around +0.15R, the setup is real.

Step 6: Forward test (paper trading)

Before trading real money, run the setup on new live data for 20–30 trades.

Use a paper trading account. Take the trades exactly as defined. Log results.

Do they match the backtest? If yes, you're ready to go live.

Common backtesting mistakes

Mistake 1: Ignoring commissions

❌ Backtest: +0.20R expectancy ❌ Commissions: $5 per trade on $50 risk = −0.10R ❌ Real expectancy: +0.10R (half of backtest)

Always include costs in the backtest.

Mistake 2: Ignoring slippage

❌ Exit at target $104 exactly in backtest ❌ In live trading: Actually exit at $103.50 (slippage) ❌ Loses 0.5% every time; hurts small samples

Model 1–2 tick slippage in backtest.

Mistake 3: Cherry-picking data

❌ "My setup works great in bull markets, so I'll backtest only 2023."

You've curve-fit to one market condition. Test in bear markets too. Test in chop.

Mistake 4: Not accounting for survivorship bias

❌ Backtest on SPY (survived since 1990)

SPY didn't exist in 1980. Companies that disappeared aren't in your data. You're testing a survivorship-biased set.

This is OK for SPY (it's the survivor). It's bad for individual stocks.

Mistake 5: Too few trades

❌ Backtest on 20 trades, see +0.3R expectancy

20 trades is luck. You need 100+ minimum, ideally 200+.

Compare Backtest vs Live, Trade by Trade

Log backtest and live trades side by side in TRADZY and see where the edge holds up.

Log Your Backtest Free →

Backtest vs. live trading differences

FactorBacktestLive
SlippageNone (or modeled)Real
CommissionsNone (or modeled)Real
ExecutionPerfectImperfect
EmotionsNoneReal (can hurt)
Stop fillsPrice-basedMight gap through
Market conditionsFixedChanging

Expect: Live results to be 10–30% worse than backtest.

If backtest is +0.2R, expect live to be +0.14R–+0.18R.

If backtest is negative, live will be worse.

Backtesting tools

ToolEaseAccuracyCost
Thinkorswim (manual)HardVery highFree
TradingView (built-in)EasyMedium (limitations)Free/Paid
NinjaTraderHardVery highPaid
AmibrokerVery hardVery highPaid
Walk-forward in ExcelHardVery highFree

Start with TradingView or Thinkorswim manual review. Graduate to coded backtests once you're serious.

FAQ

Can I backtest options?

Yes, but more complex (need volatility data). Most backtesting tools handle it.

Should I optimize for best parameters?

No. Use what makes logical sense. Optimizing creates curve-fit. Example: Don't test 50–100 SMA lengths looking for the best. Pick 50 SMA because market structure supports it.

How long should I backtest?

100–300 trades minimum. If your setup is rare, backtest a longer time period.

Can I trust a backtest?

Partially. Backtest validates the logic. Live trading validates the execution and psychology.

What if my backtest is negative?

Your setup probably doesn't have edge. Test a different setup or a different market.

Should I paper trade before live trading after backtesting?

Yes, absolutely. 20–50 paper trades to confirm results translate.

Put This Into Practice

  1. Log backtest trades with the same fields as live ones
  2. Compare win rate, average R and expectancy side by side
  3. Go live only when the numbers hold

Start Free in TRADZY →

Educational content, not financial advice. Trading involves substantial risk of loss.