How to Backtest a Trading Strategy

Trading robots have long been used in stock and forex trading. Automated cryptocurrency trading is a trend that only looks set to continue.

When we are about to use any new system the first
thing that we want to understand is how well it might perform. What kinds of
returns is it likely to reach, either on the upside or downside over certain
time periods.

While history never repeats exactly, it does rhyme as they
say. In the field of automated trading historical chart data is the main tool
that is used to examine the performance of a trading strategy.

Although testing is usually applied to system trading, a
manual trading strategy can be tested as well as long as it has a specific set
of rules.

Methods of testing a trading system

The most common way to test a strategy is through backtesting.
With backtesting, the trading strategy is run against OHLC price data over a
given period. Because most trading platforms don’t store tick-by-tick price
quotes, the backtester usually has to make some approximations.

Going through each candle (bar), the backtester feeds simulated
tick data to the trading algorithm and records the result. This is a bit like a
movie running in fast forward. The trade openings, closings and profits are
recorded over the period of the test. This creates a view of the strategy performance
over that time span.

Backtesting is good at showing the general behaviour of a
trade system, how frequently it might trade, the size of possible losses and so

Most backtesters output a full order history as well as
other useful data so that you can analyse performance from several different

It’s useful for fine tuning settings such as take profit levels,
stop losses and leverage amounts.

The main critique of backtesting is that frequently the same
data is used to both optimize and test the strategy. This creates a problem
called overfitting.
The algorithm is adapted around one set of test data. When this happens the
strategy often performs poorly when it encounters real data.

A way around this is with forward testing. With forward
testing the strategy is tested and configured on one part of the chart data. A
separate part of the data is kept clean and separate for testing purposes

Forward testing creates more reliable results because it is
known that the strategy hasn’t been over fitted.

Another approach is that of statistical testing. This doesn’t
run the algorithm through a trade simulation as back testing and forward
testing does. Instead it inspects all of the buy and sell signals that the
system creates.

Here is an example from Tradoso.


With this it works out the probabilities of the system
creating the right answer, in other words a good trade signal. For example a
good trade signal for a buy means the market has to go up more than it falls
over the trade life.

This kind of testing works not just for expert advisors. It
is possible to investigate any kind of chart signal like candlestick patterns,
the output of an indicator or even manual trades.

This is valuable both as a way of testing, but also as a way
of finding new techniques.

Paper trading

Demo trading, sometimes called paper trading can sometimes
reveal problems that won’t show up when testing against historical prices. Demo
trading will run in near market conditions so that you’ll be able to understand
how the system behaves in a real time scenario.

Demo trading is never exactly the same as market conditions,
but is near enough to be a good approximation.

All of the above techniques have a place to play in both the
testing but also in the development of any successful trading methods.


Leave a Comment

Your email address will not be published.

You may also like