Skip to main content
Behavioural Fixes That Work

Backtest Your Investing System Before Risking Real Money

Pomegra Learn

How Should You Backtest Your Investing System Before Trading Real Money?

System testing, or backtesting, is the practice of running your investment strategy against historical price data to see how it would have performed in the past. Before you risk real money on a strategy, you should have evidence that the strategy works. That evidence comes from testing.

Many investors skip this step. They develop a theory—"Buy stocks at their 50-day moving average"—and immediately start trading real money. If the theory was flawed, they lose money before they even realize it. A trader who backtests the same strategy first might discover in a week of testing what costs the real-money trader months of losses.

Backtesting is not perfect. Historical performance doesn't guarantee future results. But backtesting reveals fatal flaws. If your strategy loses money in bull markets, bear markets, and sideways markets across 20 years of data, it's probably not a good strategy. If it wins in 90% of historical scenarios, it might be.

Quick definition: System testing (backtesting) is the process of applying your investment strategy to historical price data to measure how it would have performed, revealing its edge, drawdown, win rate, and fitness for live trading.

Key takeaways

  • Backtesting is not optional if you want to trade systematically. Without historical testing, you're trading on hope and gut feel.
  • A good backtest includes: historical data of at least 10 years, realistic assumptions about costs (slippage, commissions), and careful handling of edge cases and bias.
  • The most valuable backtest metrics are win rate (% profitable trades), average profit per trade, maximum drawdown (largest peak-to-trough loss), and Sharpe ratio (risk-adjusted return).
  • Walk-forward testing (testing on data your strategy hasn't seen) is more reliable than in-sample testing (testing on data your strategy was optimized for).
  • Many investors fool themselves with overfitting—they tweak their strategy until it looks perfect on historical data, then it fails on live data because it was fit to random noise, not to real market structure.

The Purpose of Backtesting: Finding Your Edge

An edge is a reliable, repeatable advantage. A good example: "Stocks that fall 10% on heavy volume tend to rebound 5% within 30 days on average, with a win rate of 62%." If this statement is true historically, and holds in the future, you have an edge. You can build a system around it.

The purpose of backtesting is to discover whether an edge exists. If your strategy beats the market in historical data, with positive win rate and acceptable drawdown, you've found an edge. If it doesn't beat the market historically, it's unlikely to beat the market in the future.

This is not foolproof. Past performance doesn't guarantee future results. But it's far better evidence than gut feel. A strategy that beats the market in 20 years of historical data has, on average, a much higher probability of working in the future than a strategy that has never been tested.

The Anatomy of a Good Backtest

A good backtest includes several components:

1. Historical data

You need at least 10 years of data, ideally 20+. Shorter periods miss important market regimes. The years 2003–2008 include a bear market, the years 2009–2020 include a bull market, and so on. Your strategy needs to work in multiple market environments.

Make sure your data is clean and accurate. Bad data leads to misleading results. Use reliable sources like Yahoo Finance, IEX Cloud, or your broker's historical data.

2. Clear entry and exit rules

Your strategy must be mechanically executable. No vague rules like "buy when the chart looks bullish." Every decision must be testable. Example: "Buy when close > 50-day moving average AND RSI < 30 AND volume > 1M shares. Exit when close > entry price by 5% OR close < entry price by 3%."

This precision is essential. Vague rules are impossible to test accurately.

3. Realistic costs

Every trade costs money. Commissions, slippage (the difference between the price you calculated and the price you actually got), and bid-ask spreads. If you ignore these costs, your backtest will show 3% returns when real trading delivers 1% (costs ate 2%).

For stocks, assume:

  • $5–$10 per trade in commissions (or $0 if using a free broker)
  • 0.05% slippage on large positions, 0.1–0.2% on smaller positions
  • 0.01–0.05% bid-ask spread

For options, costs are much higher—sometimes 1–2% per trade. Build these costs into your backtest.

4. Position sizing

Decide in advance how big each position will be. Will you risk a fixed dollar amount ($1000 per trade)? A fixed percentage of your account (2% per trade)? The Kelly Criterion (a mathematical formula for optimal sizing)? This decision affects your returns significantly.

In your backtest, model the same sizing you'll use in live trading.

5. Handling survivor bias

Survivor bias is the tendency to notice only the successes. If you backtest a strategy on the S&P 500, you're testing only on the companies that survived and made it into the index. You're ignoring the companies that went bankrupt and were delisted. Your backtest will look better than reality.

To handle this: test on the complete historical universe of stocks, including ones that were delisted. Or at least acknowledge the bias and discount your results by 20–30%.

6. Walk-forward testing

The most common backtesting mistake is overfitting: tweaking your strategy until it looks perfect on historical data, then finding it doesn't work on new data. To prevent this, use walk-forward testing:

  • Divide your data into two parts: an "in-sample" period (2003–2015) and an "out-of-sample" period (2016–2023).
  • Optimize your strategy on the in-sample data: tweak the parameters until it looks good.
  • Then test it on the out-of-sample data (which it has never seen) without any further tweaking.
  • Compare the results. If in-sample performance is much better than out-of-sample, you've overfit.

If your strategy wins 55% on in-sample and 51% on out-of-sample, great—there's real edge. If it wins 62% on in-sample and 47% on out-of-sample, you've probably overfit.

Key Backtest Metrics

Once you've run your backtest, what numbers should you look at?

Win rate (% profitable trades)

What percentage of your trades made money? 50% is break-even (before costs). 55% is solid. 60%+ is excellent. If your win rate is below 50%, your system probably doesn't work (costs will bury you).

For example, a trading strategy that wins 60% of the time and loses 40% of the time might work—if the average win is larger than the average loss. But if wins and losses are equal size, a 60% win rate + transaction costs = profitability.

Average profit per trade

What's your average gain per winning trade, and average loss per losing trade? A strategy with 55% win rate but $100 avg loss and $50 avg gain is a loser (not worth it). A strategy with 55% win rate, $100 avg gain and $60 avg loss is a winner (math: 0.55 × $100 – 0.45 × $60 = $55 – $27 = $28 expected profit per trade).

Sharpe ratio

This measures risk-adjusted return. A strategy that gains 10% but experiences 50% drawdown is worse than a strategy that gains 8% with 20% drawdown. The Sharpe ratio accounts for this. Aim for a Sharpe ratio above 0.5. Above 1.0 is excellent.

Maximum drawdown

What's the largest peak-to-trough loss your strategy experiences in the backtest? If you need to stomach a 30% drawdown to make 8% per year, that's not appealing. If you can make 8% with only 10% drawdown, that's better. Maximum drawdown reveals the emotional toll of your strategy.

Recovery time

After a large drawdown, how long does it take to recover? A strategy that has a 30% drawdown but recovers in 6 months is more bearable than one that takes 2 years.

Profit factor

(Gross profit / Gross loss). A profit factor of 1.5 means for every dollar lost, you made $1.50. Above 2.0 is excellent. Below 1.2, the strategy is probably not worth trading.

How to Actually Backtest: Tools and Methods

Option 1: Manual spreadsheet backtest

The simplest approach: download historical price data into Excel, apply your rules manually, and calculate results. Tedious but educational. You learn your strategy intimately because you execute every rule yourself.

Example: Download daily AAPL data from 2010–2023 into Excel. Create columns for: date, close, 50-day MA, RSI. Then add a signal column: "Buy if close > 50MA AND RSI < 30." Add an exit column: "Sell if close > entry + 5% OR close < entry – 3%." Then manually track P/L. This takes hours but is valuable.

Option 2: Trading platform backtest

Many brokers offer built-in backtesting. Interactive Brokers has a portfolio margin simulator. Thinkorswim (TD Ameritrade) has a backtester. You write your rules and the platform runs them automatically on historical data. Faster than manual, less programming skill required.

Option 3: Python/R programming

If you can code, libraries like pandas, numpy, and backtrader allow you to backtest systematically. You write your rules in code, run them on historical data, and generate reports. Most powerful but requires programming knowledge.

Real-world examples

Example 1: The moving average crossover

A trader tests the simple strategy: "Buy when 50-day MA crosses above 200-day MA. Sell when it crosses below."

Backtest on S&P 500 (1990–2023):

  • Win rate: 52%
  • Average win: $2,340
  • Average loss: $2,180
  • Max drawdown: 22%
  • Sharpe ratio: 0.68

Result: The strategy is barely profitable after costs. The trader's edge is small (52% win rate with near-equal wins and losses). In real trading, with emotional pressure and slippage, this strategy would likely break even or lose. The trader redesigns it. Add a filter: "Only take signals if market is above the 200-week MA" (longer-term trend filter). Backtest again:

  • Win rate: 54%
  • Average win: $2,450
  • Average loss: $1,950
  • Max drawdown: 16%
  • Sharpe ratio: 0.92

Much better. The trader now has a real edge: win rate above 53%, Sharpe above 0.8. This is tradable.

Example 2: The earnings whisper

A trader hears that buying stocks 1 day before earnings announcements (when consensus is low) and selling 1 day after can be profitable. She backtests this on 500 stocks for 5 years:

In-sample backtest (first 3 years): Win rate 61%, avg gain 2.1%, avg loss 1.8%. Looks great.

Out-of-sample backtest (last 2 years): Win rate 49%, avg gain 1.9%, avg loss 2.2%. Disaster.

Conclusion: The strategy was overfit to the first 3 years. Market conditions changed, or the trader got lucky. The real edge doesn't exist.

Example 3: The value trap filter

A trader develops a strategy: "Buy stocks with P/E ratio < 10, sell after 1 year." Backtest on all US stocks (2000–2023):

  • Win rate: 48% (bad!)
  • But average win: $4,200, average loss: $1,800

Profit factor: (0.48 × $4,200) / (0.52 × $1,800) = $2,016 / $936 = 2.15. Excellent profit factor.

Conclusion: The strategy loses money on most trades but makes big money on the winners, and the big wins outweigh the small losses. It's profitable but emotionally grueling—you'll sit through a lot of losers. The trader accepts this tradeoff.

Common mistakes in backtesting

Mistake 1: Look-ahead bias

You use data you wouldn't have known at the time. Example: "Buy if tomorrow's volume is above average." You're looking ahead 1 day. This is invisible in a backtest but impossible in real trading. Build in a 1-bar delay—only use data from the close of today to decide about tomorrow's trade.

Mistake 2: Overfitting

You tweak your strategy 50 times until it wins 95% on historical data. But you've fitted it to noise. On new data, it doesn't work. Use walk-forward testing to prevent this. Or use the simple rule: if your strategy looks too good to be true, it probably is.

Mistake 3: Ignoring transaction costs

Your strategy looks like it returns 12% per year. But after commissions, slippage, and bid-ask spreads, it actually returns 6%. Build in costs realistically. For active trading, costs are huge.

Mistake 4: Survivorship bias

You test only on companies that survived to today. You miss the bankruptcies and delistings that hurt past investors. Your backtest looks 2–3% better than reality.

Mistake 5: Curve-fitting the backtest period

You test 1990–2023 and it works. But maybe it works only in bull markets or only in downtrends. Test separately on each market regime (bull markets, bear markets, sideways). If your system works in all of them, it's robust. If it works only in one, you don't have an edge—you have a favorable market environment.

FAQ

How much historical data do I need to backtest?

Minimum 10 years, ideally 20+. The more data, the more confident you can be that your edge is real, not luck. If your system has only 3 years of data, you've only tested through one market cycle and you don't know how it behaves in a bear market.

Is backtesting on penny stocks reliable?

Barely. Penny stocks have huge bid-ask spreads, low liquidity, and high transaction costs. A backtest might show 15% returns, but in real trading you'd get 3% due to slippage and spreads. Be very skeptical of backtests on illiquid securities.

Can I use backtests from other traders instead of running my own?

You can use them for inspiration, but you need to run your own backtest. Other traders might have overfitted, used unrealistic assumptions, or made errors. Your backtest with your rules is the only one you should trust.

What if my backtest shows losses?

That's valuable information. It means your strategy doesn't work, and you've discovered this before losing real money. Go back and redesign the strategy. Add filters, change entry/exit rules, adjust position sizing. Test again. This is how you develop an edge.

How often should I re-backtest my strategy?

Once per quarter, look for any changed market conditions or new data that might affect performance. But don't re-backtest just to tweak the strategy—that's curve-fitting. Re-backtest if you suspect a fundamental change in market structure.

Should I forward-test (paper trade) before going live?

Yes, ideally. After backtesting shows an edge, paper-trade the strategy for 1–3 months without real money. This reveals real-world friction (order fills, slippage, emotional pressure) that backtesting misses. If paper trading confirms the backtest, you have more confidence.

What if my backtest is excellent but I lose money in live trading?

This happens. Possible reasons: (1) overfitting, (2) changed market conditions, (3) higher costs in live trading, (4) emotional override of rules, (5) poor execution. Use a behavior log to identify which one.

Summary

Backtesting is the bridge between theory and practice. It transforms "I have an idea about how to trade" into "I have evidence that this idea works." A rigorous backtest includes 20+ years of data, realistic costs, clear mechanistic rules, and out-of-sample validation. Without backtest evidence, you're trading on hope. With backtest evidence, you're trading on data. The best traders backtest before trading live. They identify their edge through historical analysis, then carefully execute it in real-time. Backtesting is not perfect—past performance doesn't guarantee future results—but it eliminates obviously flawed strategies and boosts your confidence in strategies that have actually worked. The time you spend backtesting now will pay for itself many times over in avoided losses and better execution when you trade real money. A trader who spends a week backtesting before trading lives has eliminated 90% of the fatal strategy flaws. A trader who skips backtesting and trades live immediately is taking on massive, unnecessary risk.

Next

Know Your Investor Archetype