Testing Candlestick Patterns
09/07/2010 11:37 am EST
The following is an excerpt from Money-Making Candlestick Patterns: Backtested for Proven Results, by Steve Palmquist.
Candlestick patterns can be effective tools for the trader’s toolbox; however, like any other tool, the user needs to understand exactly what it is designed for and how to use it effectively. Carpenters can make beautiful things with a table saw, but they have to know how to use it and when another tool might be more appropriate for the task at hand. They also need to know the safety rules, how to avoid kickback, and the importance of using a push tool. At least the carpenters that still have all their fingers do.
The analogy holds for trading patterns. There are times when a particular candlestick pattern is effective, and times when another candlestick pattern should be used to do the job. Trading any pattern, candlesticks or some other technique, without a clear understanding of what it is and what to expect in different situations is like using a power tool without an understanding of its use and safety precautions. To protect your fingers and your money, it is a good idea to have a clear understanding of how the tools you are using work.
It is not unusual for trading patterns to have undefined or unclear parameters. Some patterns, such as the hammer, have specifications that may be interpreted differently by different traders. The same is true for Western patterns such as flags and the head and shoulders pattern. The hammer pattern requires, “little or no upper shadow.” The definition of “little” will be interpreted differently by individual traders. This is one reason that several traders using the “same” pattern may see different results. One way to address this is to study the results of many trades using different lengths of upper shadows and then to compare the results. This process results in a clear definition of what constitutes “little upper shadow” and has the added benefit of giving the trader an indication of the type of results the pattern may produce.
Some traders gain a better understanding of trading patterns, and the environments in which to use them, though experience. After trading for a number of years, they begin to understand which variations of a particular trading pattern work best, and which ones are more prone to failure. Experience often produces good results when we are listening closely; however, it can be costly.
The Tidal Force of the Market
The overall market has a strong effect on how well trading patterns perform. Focusing solely on the patterns or setups in the individual stocks that you are trading can diminish results or make them highly variable. This is another reason why traders using the same patterns may experience different results. Trading patterns are like waves at the beach; they all are affected by the tide.
Even when the tide is going out, there are waves coming in, just as there is usually something moving up even in bearish market conditions. Like conditions at high tide, when the market is bullish, we are likely to see more stocks moving up. Using different trading tools designed for specific market conditions is a process I call market adaptive trading (MAT), which we will cover in the last chapter.
In order to develop the tools and techniques for market adaptive trading, one has to be able to analyze a number of different trading tools in various market conditions and determine which are the most effective in specific market environments. After doing this, a trader can look at the market to determine the current environment, then open the trading toolbox and select the appropriate tools. Without this knowledge, the trader may be using the wrong tool, which could lead to significant drawdowns and wide account swings.
I believe a less expensive way to develop an in-depth understanding of how trading patterns work is by backtesting the pattern. Backtesting allows us to test how simple variations or changes in the trading pattern affect results. Backtesting can be done during a variety of time periods and even in specific market conditions.
You do not have to become a software engineer to backtest candlestick patterns; there are several good products available that provide backtesting tools traders can use. In fact, most of the available choices provide excellent results and probably more statistics than the average trader may care about. All of my backtesting results shown in the subsequent chapters were produced using AIQ Systems’ Trading Expert Pro. The analysis can also be done with other backtesting tools; the important thing is to make sure to do the analysis before trading a system with hard-earned money.
Backtesting allows traders to see how a system has performed in the past, to evaluate different filters and parameters, and to evaluate a system in different market conditions. Backtesting is not a guarantee of future performance. Successful backtesting requires an ability to describe the trading pattern in a backtesting language, knowledge of appropriate testing periods, an understanding of how to interpret the results, and an ability to add and test different filters or parameters to the original test description.
Article Continues on Page 2|pagebreak|
How Does Backtesting Work?
The process of describing the trading pattern in a backtesting language varies depending on which program is being used. Each software package has its advantages and disadvantages. The key is to select one that is easy to understand and use. More power and features are a waste if you cannot figure them out.
Backtesting results are typically presented in a format similar to that shown in Figure 1.12. The results in Figure 1.12 provide a lot of information, including the number of winning and losing trades, maximum profit and loss, average drawdown, the probability of winning and losing trades, annualized ROI, and other factors. It is usually not necessary to absorb all these numbers—there are really just four things that matter. The rest is interesting but not vital.
The four key things to look for in backtesting results are:
• The number of trades in the test period.
• The annualized ROI.
• The percentage of winning trades.
• The percentage profit/loss of the average winning/losing trade.
The number of trades in the test period gives you an idea of how valid the test results might be, and whether it is worth trading. A trading pattern that only produces a few trades a year may be due to seasonal or news factors and not the pattern itself. A trading pattern that produces 100 trades a year is more likely to be due to the characteristics of the pattern itself, and, therefore, has a better chance of recurring in the future.
The annualized ROI provides an indication of how well the trading pattern performs. Since the number is usually calculated by taking the percentage gain for a trade during the holding period and then annualizing the result, it can exaggerate the returns of patterns with short holding periods that do not occur very often. This is rarely the percentage return traders will see in their account because many traders cannot take all the trades generated by a trading pattern, and the calculation does not include slippage and transaction fees. The ROI number is best used as a figure of merit; more is generally better. Annualized ROI is like the gas mileage numbers posted in a car dealership—you know you will not get that exact mileage, but bigger numbers are generally better than smaller ones.
The percentage of winning trades for a trading pattern is important. If the average profit on a winning trade is larger than the average loss on a losing trade, then, in general, the more often the pattern produces a winning trade, the better the results. Imagine we are going to flip a coin 100 times, and every time it comes up heads, you give me $1.50; and, when it comes up tails, I give you $1.20. Over the long run, I expect the outcome to be profitable for me, and frankly hope you will continue to play.
The odds for each coin flip are 50/50 for heads. I do not know if any particular coin flip will be profitable for me; but, since I expect to win about half the time, and since I get paid more when I win than I have to pay when I lose, I should make a profit in the long run. Trading patterns are similar in that you do not know the outcome of any particular trade; but, if your odds of a winning trade are better than 50/50, and you make more on the average winner than you lose on the average loser, you would expect to make money in the long run.
Trading patterns should have an advantage over coin flipping; they should provide winning trades more than half the time. This stacks the odds in the trader’s favor. If a trading pattern wins more than 50% of the time, and the average winning trade gains more than the average losing trade loses, then trading is a better game than the coin flip example. The stock pattern trader still does not know if any given trade will be profitable, but over the long run, the odds are favorable for the net result to be profitable. Traders do not focus on the results of any one trade, they focus on whether or not the account balance is going up over the long run.
While backtesting can yield great insight into how candlestick patterns perform and the risks associated with particular trading patterns, they need to be run over a specific time frame. Choosing that time frame can be confusing. Many people initially feel that the longer the time frame of the backtest, the better the results. Figure 1.13 illustrates why there is a better way to select time frames for backtesting.
Figure 1.13 shows the NASDAQ market over a 14-year period. If backtesting is done over a specific time period, then one is assuming that the next period of similar length will be just like the previous period. If one tests a trading pattern over the 2004 to 2007 period and uses the results to trade in 2007 to 2010, the trader is expecting the 2007 through 2010 period to look similar to the 2004 through 2007 period. This may at first seem reasonable, but further examination of Figure 1.13 reveals that it is hard to find two four-year periods that look just like each other.
The market is always changing; we do not know what it will look like in the future. There is one constant though: Each market time frame is made from a collection of bullish, bearish, and trading range periods. The market is either going up, down, or sideways. It is impossible for it to do anything else. This indicates that trading patterns should be tested in each of the three conditions, and then traders should select the patterns that they have found to be most effective during the current conditions. Yes, testing a trading pattern over a calendar time frame is also good. But use more than one time period and also look at performance in each of the three types of market conditions to gain a better understanding of how a potential trading system performs and when to use it.By Steve Palmquist, author, Money-Making Candlestick Patterns: Backtested for Proven Results