What is a backtest?
A backtest is a simulation of how a trader with a mechanical trading system would have responded to market data, i.e by buying, selling, or forgoing any transaction at all. Backtesting is a way of testing the signals given by a trading system in order to see whether it would have been profitable in the past.
As with any simulation, the more realistic the backtest, the more useful it is. Obviously, the goal of any trader is to maximize return after slippage and transaction costs (while avoiding unnecessary risk) and these costs should of course be included in the test.
 The data mining problem
Just because a strategy would have worked in the past had a traderstumbled upon it does not necessarily mean it is reasonable to think it will continue to work in the future. The Super Bowl Indicator (NFC team wins, market goes up) and the hemline indicator (skirts long, sell short) are obvious examples, but don't be lulled into thinking that any strategy based on more sensible criteria is sure to work. Backtesters must be careful to avoid hyping results based on a limited set of data. There may be something special about the data the backtester used (e.g., it's all January data) that causes anomalous results. Or the results may simply have been caused by chance.
Data mining is even more of a hazard as backtesters use new programming techniques and greater computer horsepower. "Genetic algorithms" sometimes spit out eye-popping numbers when using historical data. It remains to be seen whether these algorithms actually help predict anything. As O'Shaugnessy said in What Works on Wall Street, "Torture the data enough and it will confess to anything."
 How to combat the data mining problem
There are three primary ways to combat data mining.
The most obvious is to view with suspicion results that contradict common sense or other well-designed studies.
The second way to avoid data mining is to divide the available historical data into a "play" set and a "confirmation" set. Use the play set to experiment with, and then see if the confirmation set confirms your hypothesis. For example, if you had 5 years of data at your disposal to test an intra-day system, you might have a play set of 24 randomly selected months and a confirmation set of 24 different months. This method is almost sure to tell you whether you are really eliminating problem children or just trying too hard. If you do not have fairly large set of data to start with, you cannot use this technique. Be very cautious in interpreting your results.
The third way is to avoid over-optimising or "curve fitting" your system. By this I mean continually tweaking and adding parameters in ordre to increase the overall profitability. Do this to excess and you are likely to end up with a brilliant system for the period of time under scrutiny, but one that fails miserably as market conditions change. The best systems tend to be fairly simple.
 Results of a backtest
Here are the questions most traders want a backtest to answer before putting money into a trading system: