The double top pattern is a chart formation consisting of two consecutive price peaks that leads to a bearish reversal.
For years, traders have claimed that the double top is a high probability short setup.
This is because a double top pattern signifies that bulls are having trouble pushing the price past the prior high.
However, there has been little statistical research done to prove whether or not this pattern has any predictive ability.
In this article, we come up with a definition for the double top, code it up and test the pattern on some historical data.
1. Define The Double Top Pattern
Before we go any further it’s important to think about what a double top actually is and how we can write it into code.
This always presents a problem with chart patterns because they only become clear after the pattern is completed.
For example, a double top pattern only looks like a double top after the stock hits a high then drops through the accompanying support area.
If the stock doesn’t drop fully, then it will look more like a wedge or a triangle pattern.
If the high doesn’t hold long enough then the double top pattern very quickly looks nothing like a double top at all and instead morphs into a typical breakout.
Because of this, it’s essential to come up with a mathematical formula to represent a double top.
This won’t be perfect but it will be our best bet if we want to analyse the effectiveness of the pattern.
Two Peaks And A Neckline
Most descriptions of a double top include two price peaks and a supporting neck line.
It is this neckline that must be broken for the double top pattern to be completed.
A typical double top can therefore be broken down as follows:
However, coding this pattern is more tricky than it sounds because we need to be specific about certain criteria such as:
- How to define the first peak (A)?
- How much should the high at peak A differ from the high at peak C?
- What should the distance be between the neckline and the highest peak?
- How many bars should there be between peak A and peak C?
- What is the maximum number of bars that the pattern should complete within?
Our solution to this problem is to code up the pattern according to the points above and also make them adjustable parameters.
We can then run an optimization to see which settings work best in the context of a double top pattern.
Importantly, the settings should be set so as to not lose the essence of what a double top represents.
We therefore decided that a double top pattern occurs when all the following conditions are true:
- The first peak A must be the highest High price in [126,252] trading days
- The High prices at Peaks A and C must differ by less than 1%
- The lowest High price between the peaks (i.e. the bottom of the trough) must not be more than [20,30,40,50,60] % below the highest peak
- Consecutive peaks must be at least [10,20,30,40,50] bars apart
- The whole pattern must occur within [63,126,189,252] trading days to be valid
- The pattern completes after the second peak occurs and the High price falls below the lowest High between the peaks (B).
Here is a snippet of the Amibroker code we came up with:
Now we can see a real example of the kind of trade setup we can identify with this double top code in NRG:
2. Set Up The Backtest
Now we have some code written for our double top pattern we can run some optimizations and see how the pattern performs on historical data.
But first we must define a backtest procedure and think about a baseline that we can use to compare our results.
For this analysis we decided to test the performance of double top patterns on all S&P 500 stocks across holding periods from one to ten days.
We also decided to use an in-sample period and out-of-sample period.
This enables us to run an optimization during the in-sample segment and then test it on the cleaner out-of-sample data.
For a benchmark, we decided to compare our results to the average return for every stock in the sample with a corresponding holding period.
For example, if the average 5-day return for all stocks in the sample is 0.5% but our pattern produces an average return per trade of 2%, there’s a good chance that we have found a profitable trading signal.
The procedure for this is to each day select all stocks that are members of the S&P 500 and calculate the closing price N-days in advance and calculate the average return over that holding period for all symbols.
This is summarised below:
Summary Baseline Returns For S&P 500 Stocks:
- 1 Day: 0.016%
- 3 Days: 0.101%
- 5 Days: 0.184%
- 10 Days: 0.386%
You can see that the average daily return for all stocks is 0.016% (open to close) while the average return is 0.386% over 10 days. There is a slight upward bias to the results which is expected.
Note: You can also flip these results in order to see the average returns from going short instead of long. So, the average short return over 10-days is -0.386%.
Our full backtest settings can now be summarised as below:
- Test universe: All S&P 500 stocks including historical members
- In-sample test period: 1/2000 – 1/2012
- Out-of-sample test period: 1/2012 – 1/2018
- Commissions: 0
- Liquidity filter: Close > $2 and 21-day turnover > $250,000
- Holding periods: 1-day, 3-day, 5-day, 10-day
- Execution: Enter short position on the next day open after the pattern completes. Exit position on the close of the corresponding day
- Baseline: Average return for all stocks in the sample by holding period
In the next table you’ll be able to see the results of our optimization during the in-sample period.
We are optimizing four strategy parameters here and looking for the best combination during the sample period between 1/2000 – 1/2012.
We have also filtered out any results that have less than 150 trades because we want to have a decent enough sample size.
You can see from the above that some variations of our double top pattern have a slight edge with an average profit per trade of up to 0.39%. You can also see that some variations have win rates as high as 56%.
Any variations with more than 150 trades and an average profit per trade >= 0.20% are highlighted green.
The best performing variation #321 produced an average profit per trade of 0.39% with a 50% win rate. This double top pattern had the following settings:
- Max 1% difference between peak 1 and peak 2
- Peak 1 is highest in 126 days
- 20% max peak to trough
- 20% min peak to peak bars
- 189 bars max length
- 3-day holding period
Compare To Out-Of-Sample
We have seen some small profits during the in-sample optimization, the next question is do these same variations hold up in the out-of-sample test period?
In the next table in-sample data for Avg % P/L has been added and the OOS results are sorted based on the highest IS Avg % P/L.
You can see that of the 19 variations with the highest in-sample average profit per trade (highlighted green) only two achieved an average profit per trade over 0.20% in the OOS test (highlighted yellow):
For example, variation #321 produced an average profit of 0.39% profit in-sample and a profit of 0.23% out-of-sample with a 3-day holding period.
This compares to an average 3-day short return of -0.101% for all stocks in the sample. We get this from our baseline result, implying there’s a small element of profit but not much.
Overall, with a fairly low average gain per trade (even before commissions) and also a small number of trades (10-30 per year), other significant improvements would be required to turn this into a profitable trading strategy.
There may be some benefit to a double top pattern as a hedge to a long strategy but profits of only 0.2% are unlikely going to cut it when we introduce commissions and slippage.
Also, it appears hard to predict which parameters will be successful in the future. There’s not enough profit and not enough stability in the results to be confident in this pattern.
One positive conclusion we can make is that short trades seem to work better over short holding periods – 3 days or 1 day. This information might be useful for a future experiment.
5. Intraday Test
Before we wrap up, I also wanted to run some analysis on intraday markets to see if double top patterns are more profitable on higher frequency data.
For this, I tested 15-minute time-frames for five major ETFs; SPY, QQQ, GLD, USO and TLT.
For these tests, we had to make a few changes to get reliable results and find entries that still look like double tops.
The code for the second peak was altered so that it must occur within 0.1% of the first peak.
The other difference was that any short trade must be placed before 2pm and all trades are exited on the close at 4pm.
This is because we want to keep this test strictly to an intraday timeframe.
The tables below show our top 10 optimization results for different ETFs:
TLT 15 minute:
Unfortunately the answers are again disappointing for this analysis (with the exception of USO).
For example, you can see that for SPY the best performing pattern produced an average profit of only 0.06% per trade while we found no profitable setup for GLD at all.
This is quite unusual for an optimization and we were struggling to find enough trading opportunities for this symbol.
Meanwhile, USO produced profits up to 0.81% per trade but the sample sizes were also small so more investigation would be needed.
6. Final Thoughts
We often hear traders talking about winning chart patterns like double tops and head and shoulders but time and again we test these patterns and find very little evidence of profitability.
There can only be 3 reasons for this dissonance:
- Some traders are making money from these patterns but they’re profits are actually due to luck and not chart reading.
- Some traders are making money from these patterns but they are incorporating other tricks and secret sauce that helps them to win.
- Traders are deluding themselves and actually not making money from these patterns at all.
All three reasons are perfectly believable and I have witnessed them numerous times through my years of trading.
The difficulty with markets is that it is all a big numbers game.
You will always have some winners due to the nature of statistics. It doesn’t follow that results are necessarily borne out of skill or a found edge.
Looking at the results of the double top, this is not a pattern you want to be shorting on its own. The results simply aren’t good enough.
If you are interested in more successful trading setups, quantitative analysis and trader education, make sure to check out our full program at Marwood Research which includes 30+ complete trading strategies and codes.