Skip to content
Advantrade Capital Limited

Strategy Backtesting: How to Test a System on Historical Data

Step by step: how to run a reliable strategy backtest, avoid the pitfalls of overfitting and build a data-driven system.

StrategyApril 12, 202615 min read
🎯

What is backtesting?

Backtesting is the process of verifying a strategy on historical data to assess its potential effectiveness before deploying it on the market. Without a backtest, every strategy is nothing more than a hypothesis. With a well-executed backtest, it becomes a measurable tool with a known statistical risk-and-reward profile.

The thinking behind a backtest is simple: "If I had used this strategy for the past 2 years, how much would I have made?" The answer to that question does not guarantee future profits, but it eliminates strategies that are mathematically doomed to fail. That is the difference between playing the lottery and running a business.

Preparing the data

The first step is preparing the data. The quality of historical data determines the credibility of the entire backtest. The data should include OHLCV prices (Open, High, Low, Close, Volume) at the desired granularity — at least 1-minute data for day trading, 1-hour or daily for swing trading. Sources split into free (Yahoo Finance, Kaggle) and paid (Quandl, IQFeed, TrueFX for forex).

For a rigorous backtest, investing in premium data is recommended, especially for the forex and futures markets, where free data often contains errors, missing points or incorrectly adjusted prices. In forex, the quality of tick data is particularly important — without it, the backtest does not account for the real spread and slippage.

💡 Key lesson: A minimum of 2-3 years of historical data, covering different market conditions (uptrend, downtrend, consolidation, high and low volatility). A backtest over 6 months of a bull trend says nothing about how the strategy will behave in a recession.

Defining the rules

The next stage is defining the strategy rules in an unambiguous, reproducible way. Every rule must be formulated as a logical condition: "if the 50-day moving average crosses above the 200-day and RSI is below 70, then buy". Vague phrasing like "when the market looks strong" leads to subjective interpretation of results.

Also define: position size, stop-loss, take-profit, emergency exit conditions, the maximum number of open positions and the trading schedule. A strategy without clear exit rules is incomplete — the entry is only 30% of the equation.

If you cannot describe your strategy in 5 sentences in a way others could reproduce — it is not a strategy, it is hope. A backtest requires precision, not intuition.

Overfitting and look-ahead bias

The key pitfalls are overfitting — a strategy fitted too closely to historical data, losing its ability to generalise — and look-ahead bias, i.e. using information that was not available at the given moment. Overfitting arises when you keep adding conditions until the strategy shows perfect results on the training data. In reality, such a strategy has "memorised" history rather than understood the market.

Fighting overfitting means limiting the number of parameters (a maximum of 3-5 input variables) and splitting the data into training (60%), validation (20%) and test (20%) sets. A strategy that works on all three sets has real potential. One that only shines on the training data — does not.

Performance metrics

Interpreting the results requires understanding the metrics. Max Drawdown shows the worst-case scenario — the decline from peak to trough. If Max DD is 25%, you must be mentally prepared to lose a quarter of your capital. The Sharpe Ratio measures return relative to volatility — above 1.0 is a good result, above 2.0 is outstanding. A Profit Factor above 1.5 indicates a profitable strategy. The Win Rate — the percentage of winning trades — matters less than it seems. With an R:R of 1:3, a 30% win rate is profitable.

A minimum of 100 trades is the threshold of statistical credibility. 20 winning trades in a row proves nothing — it could be pure luck. A backtest across 500+ trades gives a far more reliable picture.

Summary

Backtesting is an investment of time that saves you an investment of money. Get good data, define clear rules, split the data into sets and evaluate the results coolly — without emotion. Remember: even a perfect backtest does not guarantee future profits. It only guarantees that you are entering the market with your eyes open, not closed.

#backtesting#strategy testing#historical data#optimisation#overfitting
Caroline Wright

Caroline Wright

Cryptocurrency Analyst and Author

Senior market analyst with years of experience in the financial markets. Specializes in technical analysis, risk management, and retail investor education.

Legal notice: This article is for informational and educational purposes only. It does not constitute investment advice or a trading recommendation. Trading CFDs involves a high risk of capital loss. We recommend consulting a financial advisor before making any investment decisions.

Stay on top of the markets

Get weekly market analysis, trading strategies and exclusive educational materials delivered straight to your inbox.

No spam. Unsubscribe at any time.

Back to blog
Blog | Advantrade Capital Limited