Introduction
In this article we introduce the notion of backtesting and its implementation in CandleScanner, which will be discussed over several articles.
There is an extensive, and technical, literature on backtesting, including pitfalls, and here we can only scratch the surface. Backtesting can concisely be described as ‘…the process of applying a trading strategy or analytical method to historical data to see how accurately the strategy or method would have predicted actual results.’ Developing a trading system, and here we are concerned with ‘algorithmic’ (mechanical) trading systems, requires a set of predefined rules which can be translated into a series of parameters, conditions and resulting actions. The rules will generate buy and sell signals i.e. when to enter and when to exit a trade.
One advantage of rules-based systems is that they are free of emotional bias and judgement, and, importantly, are testable. Hence, a trading system is the combination of a model and the data which the model addresses. The data being analysed consists of a combination of the underlying signal, which the model is attempting to capture, and ‘noise’, which is what is left unexplained. In other words, the model is attempting to captures the patterns contained in the signal. There are many potential models, and in CandleScanner the patterns are the observed candlesticks.
Many traders will often combine candlestick patterns with other signals, regarded as confirming signals, and hence, the combination is seen as providing a higher probability for a successful entry or exit signal. Traders have a variety of such technical signals to choose from, a number of which are also available in CandleScanner. Either way, it is important to assess how effective the trading system would have been in the past, based on historic prices. CandleScanner has the capability enabling the various candle patterns to be evaluated i.e. did the patterns in the past generate profitable signals, and, can the patterns be used to trade profitably in the future?
Analysis: CandleScanner backtest inputs
In CandleScanner there is screen which enables customised settings for the backtest to be set. First select the Tests icon in the Home ribbon followed by the Settings tab (see Figure 1.) Finally, make your selections, for example Group together with the Symbol(s) you wish to analyse, the period, the Position and Pattern you wish to test (fuller details and explanations are provided in the User Guide). It is also possible to set custom backtest settings for long/short positions such as:
- entry and exit positions (from a choice of price conditions)
- stop loss
- trailing stop (i.e. active true range or fixed distance)
- take profit (i.e. the price level at which profit is taken)
- any number of backtesting schemas can be set
Inputs with be further considered in Part 2 of the article. However, we would here like to draw attention to the fact that a complete trading system consists of more than an entry/exit strategy. A fuller and detailed evaluation of the trading system requires consideration of aspects such as trading costs, money management techniques, position sizing and maximum drawdown (specialised software for this exists, for example Adaptrade’s Market System Analyser, and as such, CandleScanner will enable the results to be exported for further in-depth analysis). In future articles we will get into more detail, including the fact that having a nice and smooth equity line in the backtest is not what we should expect during real trading (the so-called ‘curve fitting’ pitfall!).