Last Updated on March 24, 2021 by Oddmund Groette
This article explains candlesticks and why we like to use candlesticks when displaying charts. Moreover, we test quantitatively 23 different candlestick formations. Perhaps surprisingly, some of the formations work pretty well. Some of the formations can highly likely be improved by adding one more variable.
Candlesticks are a popular way to display quotes on a chart, something we have done since we read Gregory Morris’ Candlestick Charting Explained back in 1998. However, we have never implemented candlesticks in any of our quantified strategies.
Why do we use candlesticks in our charts? We agree with Mr. Morris, who writes this in the introduction of the book:
However, once you become accustomed to seeing Japanese candlestick charts, you will prefer them because their clarity is superior and allows a quick and accurate interpretation of the data.
Mr. Morris is right. Candlesticks are easy to digest once you get used to them.
If you have never seen a candlestick, it might be a little confusing to start with, but once you get used to candlesticks, you get a much better visual look of the charts – for example, where the stock opened and closed.
A black candlestick means the open was higher than the close, while a white candlestick means the close is higher than the open. The difference between the open and the close is called “the body”. The “tails” on both sides are the high and low readings that day (or whatever time frame you are using):
Candlesticks might have an appealing and/or easy interpretation, but does it add any value?
Are candlesticks reliable?
A quick search on the internet reveals many articles touting candlesticks’ importance and what formations to look for. Endless articles explain the formations, but as usual, without any empirical evidence about their predictive power. That’s a shame because it’s relatively easy to test candlesticks. Further down in the article, we reveal some quantitative results from 23 formations.
How many candlesticks are there?
Exotic names like Hanging Man, Bullish Engulfing Pattern, Shooting Star, Bullish Hikkake, One White Soldier, Bearish One Black Crowe, Piercing Line, and Hammer are just a few of the candlestick formations that exist. We have no idea how many candlesticks formations there are, but if you like to know more about candlesticks, we recommend this page.
Do candlesticks work best in daily or intraday bars?
We recommend using different timeframes in your trading, but with candlesticks, they seem to work best on daily bars and not on shorter time frames (intraday). Daily bars seem to be more reliable than intraday bars. Among many, the reasons are that there are many more transactions in daily bars than intraday ones, and daily bars, in general, attract more attention.
How to quantify candlesticks:
To test candlesticks quantitatively, we need to make rules based on strict criteria. Like most things that can be labeled technical analysis, no specific or mathematical definition of the candlesticks formations exists. However, most of the formations can be fairly easily defined and is already done by many on the internet.
A strategy is not complete until you have exit criteria. Candlestick formations only look at “bullish or bearish” setups without considering any exit criteria. Thus we need to make our own criteria for when to close the position. We used the same exit rule as we often use: to sell on short-term strength when today’s close is higher than yesterday’s high. The exit criteria are a vital part of any strategy and can, of course, change results dramatically. Even a strategy based on random entry can generate splendid results using the “correct” exit criteria. And, honestly, when testing the candlestick formations, it would probably be fairer if we had different exits based on the number of days since entry. But we leave that test to another day.
Amibroker code for candlesticks:
To make it easier for you to test and develop, we paste the code below from Wise Stock Trader. Similar code can be found on multiple websites. We have not verified all of the code, but the code seems to fit very well to the formations. We have slightly altered the code for a couple of the strategies.
The “//” in the code below means the text is not part of the code but is put there to label the formation.
O1 = Ref(O,-1);
O2 = Ref(O,-2);
H1 = Ref(H,-1);
H2 = Ref(H,-2);
L1 = Ref(L,-1);
L2 = Ref(L,-2);
C1 = Ref(C,-1);
C2 = Ref(C,-2);
Buy= ( ( (C1 < O1) AND (C > O) AND (O < C1) AND (C > O1) ) // Bullish Engulfing
( (C1 > O1) AND (C < O) AND (O > C1) AND (C < O1) ) // Bearish Engulfing
( (C1 < O1) AND (((O1 + C1)/2)< C) AND (O < C) AND (O < C1) AND (C < O1) ) // Piercing Line
( (((H – L)>2*(O – C)) AND ((C – L)/(H – L)>0.66) AND ((O – L)/(H – L)>0.66)) ) // Hammer
( ((H – L)>4*(O – C) AND ((C – L)/(0.001 + H – L)>= 0.75) AND ((O – L)/(0.001 + H – L)>= 0.75)) ) // Hanging Man
( ((H – L)>3*(O – C) and ((h – c)/(0.001 + h – l)> 0.6) and ((h – o)/(0.001 + h – l)> 0.6)) ) // Inverted Hammer
( (((H – L)> 4*(O – C)) AND ((H – C)/(.001 + H – L)>= 0.75) AND ((H – O)/(.001 + H – L)>= 0.75)) ) // Shooting Star
( ((O > C) AND ((H – L)>(3*(O – C))) AND (((H – O)/(.001 + H – L))< .4) AND (((C – L)/(.001 + H – L))< .4)) ) // Black Spinning Top
( ((C > O) AND ((H – L)>(3*(C – O))) AND (((H – C)/(.001 + H – L))< .4) AND (((O – L)/(.001 + H – L))< .4)) ) // White Spinning Top
( ( (C2 > O2) AND (O > C) AND (L1 > H2) AND (L1 > H)) ) // Bearish Abandoned Baby
( ((C2 > O2) AND ((C2 – O2)/(.001 + H2 – L2)> .6) AND (C2 < O1) AND (C1 > O1) AND ((H1 – L1)>(3*(C1 – O1))) AND (O > C) AND (O < O1)) ) // Bearish Evening Doji Star
( (C1>O1 AND ((C1+O1)/2)>C AND O>C AND O>C1 AND C>O1 AND (O-C)/(.001+(H-L)>0.6)) ) // Dark Cloud Cover;
( (C2 > O2) AND (O1 > C1) AND (O1 >= C2) AND (O2 >= C1) AND ((O1 – C1)>(C2 – O2)) AND (O > C) AND (C < C1) ) // Three Outside Down Pattern
( (C1 == O1) AND (O2 > C2) AND (C > O) AND (L2 > H1) AND (L > H1)) // Bullish Abandoned Baby
((O2 > C2) AND ((O2 – C2)/(.001 + H2 – L2)> .6) AND (C2 > O1) AND (O1 > C1) AND ((H1 – L1)>(3*(C1 – O1))) AND (C > O) AND (O > O1)) // Bullish Morning Doji Star
((O2 > C2) AND (C1 > O1) AND (C1 >= O2) AND (C2 >= O1) AND ((C1 – O1)>(O2 – C2)) AND (C > O) AND (C > C1)) // Three Outside Up Pattern
( (O1 > C1) AND (C > O) AND (C <= O1) AND (C1 <= O) AND ((C – O)<(O1 – C1)) ) // Bullish Harami
( (O2 > C2) AND (C1 > O1) AND (C1 <= O2) AND (C2 <= O1) AND ((C1 – O1) < (O2 – C2)) AND (C > O) AND (C > C1) AND (O > O1) ) // Three Inside Up Pattern
((C1 > O1) AND (O > C) AND (O <= C1) AND (O1 <= C) AND ((O – C)< (C1 – O1))) // Bearish Harami
((C2 > O2) AND (O1 > C1) AND (O1 <= C2) AND (O2 <= C1) AND ((O1 – C1)<(C2 – O2)) AND (O > C) AND (C < C1) AND (O < O1)) // Three Inside Down Pattern
(C > O*1.005) AND (C1 > O1*1.005) AND (C2 > O2*1.005) AND (C > C1) AND (C1 > C2) AND (O < C1) AND (O > O1) AND (O1 < C2) AND (O1 > O2) AND (((H – C)/(H – L))< .3) AND (((H1 – C1)/(H1 – L1))< .3) AND (((H2 – C2)/(H2 – L2))< .3) // Three White Soldiers
( (C1>O1*1.01) AND (O>C) AND (O>H1) AND (C>O1) AND (((C1+O1)/2)>C) AND (C>O1) AND (MA(C,13)-Ref(MA(C,13),-4)>0) ) // Dark Cloud Cover
( (O > C*1.005) AND (O1 > C1*1.005) AND (O2 > C2*1.005) AND (C < C1) AND (C1 < C2) AND (O > C1) AND (O < O1) AND (O1 > C2) AND (O1 < O2) AND (((C – L)/(H – L)) < .3) AND (((C1 – L1)/(H1 – L1))< .3) AND (((C2 – L2)/(H2 – L2))< .3) ) ) // Three Black Crows ;
buyPrice = Close;
Sell = Close > Ref(H,-1);
sellPrice = Close ;
Why use Amibroker and not, for example, Tradestation?
The results are in: Do candlesticks work?
Some of the formations are meant as bearish formations. Nevertheless, we test all formations by buying, not selling/shorting.
We tested the 23 formations on the S&P 500 using the ETF SPY from its inception in 1993 until the end of November 2020. The results are summarized in this table:
Some of the formations give many signals, while others produce few signals. Only one formation, Three White Soldiers, produces negative returns, perhaps not surprising because it goes long after three days when the close is higher than the opening. As most of the readers probably know, the stock market is highly mean-reverting in the short-term.
What happens if we trade only the strategies with a higher profit factor than 1.5? That is 12 patterns in total.
The compounded result is good: 975 trades, CAGR is 12.89%, the average gain is 0.36% per trade, max drawdown is 25%, and the profit factor is 2.02. The only negative year was 1994 and the total time spent in the market is 47%. The best year was 2020, with almost 41% return from 40 trades (!). Buy and hold was 9.9% during these 25 years.
The equity curve looks like this (no commissions and slippage):
The chart is compounded, starting with 100 000 in 1993.
Do these 12 candlesticks patterns work on other ETFs (those formations with a profit factor above 1.5)? Here is a list of a random sample:
- QQQ: 12.9% CAGR
- TLT: 5.5% CAGR
- XLP: 9% CAGR
- GLD: 0.3% CAGR
- EEM: 16% CAGR
- GDX: 12.2 CAGR
Do you want to get monthly profitable Trading Edges? Sign up for our subscription service:
How to trade and use candlesticks?
To improve the results, you might want to add a variable. This variable could, for example, be:
- The direction of the long-term trend, for example, a moving average filter
- By using an ADX filter
- Include a short term RSI filter.
Some candlestick formations show some promise, but most of the formations give few signals. However, the slightly data-mined test of using the 12 best formations beat buy and hold. This is promising considering that the time spent in the market is 47%, and the drawdown is just half of buy and hold.
As usual, you need to backtest yourself and test ideas you might have.
For more trading ideas, check out this page:
Disclosure: We are not financial advisors. Please do your own due diligence and investment research or consult a financial professional. All articles are our opinions – they are not suggestions to buy or sell any securities.