Testing a strategy on historical data by applying its rules as they would have been executed. It helps discard bad ideas; it does not guarantee future results.
Backtesting means applying the rules of a strategy to past data, trade by trade, to measure how it would have performed. You can do it by hand, scrolling through charts and logging each signal, or with software that automates the rules. Its real value lies in elimination: if an idea does not work even in the past, it will probably not work tomorrow.
A good backtest starts with fully defined rules: entry, exit, stop loss, size and filters. It then needs quality data covering enough years and different market phases, trending and ranging, high and low volatility. With 40 trades the result is unreliable; figures start to be reasonable with several hundred trades, and even then uncertainty remains.
Include realistic costs. Example: a system has a gross expectancy of 0.15R per trade. If spread, commission and slippage cost 0.05R, net expectancy is 0.10R. Over 200 trades, that is 30R versus 20R: a third of the result evaporates in costs. A backtest without costs almost always overstates performance, especially on short timeframes.
Biases are the great enemy. Look-ahead bias uses information that was not available at that moment, for example a daily close before it happens. Survivorship bias analyses only instruments that still exist. Poor data, without variable spreads or real gaps, gives optimistic results. In futures, continuous series also smooth over the jumps at contract rollovers.
To check that you are not fitting noise, split the data: use part of it to design and optimise (in-sample) and keep another part untouched for validation (out-of-sample). If two years of training yield a profit factor of 1.8 and the following validation year drops to 1.1, that is a warning sign. Walk-forward validation repeats this process over successive windows.
Backtesting does not replace demo trading or trading at minimum size: live execution adds latency, rejections, wider spreads around news and emotions. Treat the backtest result as the ceiling of expected performance, not the floor.
In risk management, it helps you estimate historical maximum drawdown and the worst losing streak, and from there size positions so that enduring that drawdown is viable. Then mentally multiply it by 1.5 or 2, because the worst case in history has not happened yet.