Summary of Candlestick Backtesting

This post summarizes the candlestick back-testing so far.

To understand the effectiveness / profitability of these signals, I choose to look at two measures of performance.
  • Number of Trades : The number of trades is number of times the particular showed happened during the back-test period. There are two inferences from this number:
    • If the number is small, the results are not statistically reliable.
    • The number provides an insight into the prevalence of the signal. This is important when building a system 
  • Win-Rate : The win rate represents number of times this particular signal was profitable. Looking forward, this can be thought of the probability that this signal will be profitable
The back-tests were done on the SP500 symbols over the past 15 years.


PatternWin-RateNumber of Trades
Doji52.72%3403
Bullish Engulfing Pattern45.60%6268
Bullish Harami47.87%3787
Hammer46.71%2387
Bullish Kicker Pattern54.6%1511

Backtesting the Bullish Harami Pattern

This is the third post in my three part series of backtesting a candlestick patterns. Earlier, I back-tested the Bullish Engulfing Pattern and the Hammer. Today, I will back test the Bullish Harami Pattern.

Quantifying the Hammer

A Bullish Harami pattern is formed when all the following conditions should be met :

  1. today's bar is white (up day) and yesterday's bar is dark
  2. today's candle height is less than yesterday's candle body
Back Testing the Pattern
 
DataSet : SP500
BackTest Period : 15 years

Buy Signal :
  •  Look for 3 consecutive down days
  • A Bullish Harami is formed on the third day and the fourth day
  • Buy at Open on the fifth day
Sell Signal:
  • Sell on the sixth day

Performance

I am only interested in finding out if this particular signal does act as a trend reversal signal. I am not interested in building a trading system. The best performance measure for this task is the Win-Rate as it represents the probability that my hypothesis is correct.


PERFORMANCE
Number of Trades2,387Winning Trades1,115Losing Trades1,272
Average Profit %-0.27%Win Rate46.71%Loss Rate53.29%
Average Bars Held2Average Profit %2.54%Average Loss %-2.73%
Average Bars Held2Average Bars Held2


Setup

Backtest the Hammer

This is the second post in my three part series of backtesting a few candlestick patterns. Earlier, I back-tested the Bullish Engulfing Pattern. Today, I will back test the Hammer.

Quantifying the Hammer

A Hammer pattern is formed when all the following conditions should be met :
  1. today's bar is white (up day) followed by three down days
  2. Candle's body height is less than 40% of the total candle height
  3. Close is located near the top of the candle


Back Testing the Pattern
 
DataSet : SP500
BackTest Period : 15 years

Buy Signal :
  •  Look for 3 consecutive down days
  • A Hammer candlestick is formed on the fourth day
  • Buy at Open on the fifth day
Sell Signal:
  • Sell on the sixth day

Performance

I am only interested in finding out if this particular signal does act as a trend reversal signal. I am not interested in building a trading system. The best performance measure for this task is the Win-Rate as it represents the probability that my hypothesis is correct.



PERFORMANCE
Number of Trades3,787Winning Trades1,813Losing Trades1,974
Average Profit %-0.21%Win Rate47.87%Loss Rate52.13%
Average Bars Held2Average Profit %2.68%Average Loss %-2.86%
Average Bars Held2Average Bars Held2
  

Setup



 



Backtesting Bullish Engulfing Pattern

In my blog post yesterday, I said that I will be back testing three candlestick patterns. Today, it is the Bullish Engulfing Pattern.

Quantifying the B-E Pattern

A Bullish-Engulfing pattern is formed when all the following conditions should be met :
  1. today's bar is white (up day)
  2. yesterday's bar is dark (down day)
  3. today's trading range is larger than yesterday's
  4. today's close is greater than yesterday's open
Backtesting the pattern

DataSet : SP500
BackTest Period : 15 years

Buy Signal :
  •  Look for 3 consecutive down days
  • A Bullish-Engulfing candlestick is formed on the fourth day
  • Buy at Open on the fifth day
Sell Signal:
  • Sell on the sixth day

Performance

I am only interested in finding out if this particular signal does act as a trend reversal signal. I am not interested in building a trading system. The best performance measure for this task is the Win-Rate as it represents the probability that my hypothesis is correct.


PERFORMANCE
Number of Trades6,268Winning Trades2,858Losing Trades3,410
Average Profit %-0.37%Win Rate45.60%Loss Rate54.40%
Average Bars Held2Average Profit %2.56%Average Loss %-2.83%
Average Bars Held2Average Bars Held2

In this particular example, there are two things I would like to note :
  • Bullish Engulfing patterns happen quite often. For the SP 500 stocks in the last 15 years, they showed up about 400 times in one year
  • They are NOT very good at predicting a trend reversal. For the SP 500 stocks in the last 15 years, they were correct only 45% of the time

Buy Setup



More on Candles

My recent forays into candlestick patterns has not been very encouraging. I tested the doji as a trend reversal signal and the results were not impressive.

On doing some more research, I came across candlestickgenius.com. They claim to be fairly successful at spotting candlestick pattern and have a description on the most reliable candlestick patterns. In the next few posts, I will be testing three of these patterns and presenting the results.

Bullish Engulfing

Bullish engulfing pattern is formed when
  • today's candle is taller than previous day's
  • today's candle body is taller than previous day's
  • today's candle is white and the previous day's is black

Hammer
A hammer is formed when:
  • today's candle is white
  • today's candle body is short in relation to the candle height
  • today's candle body is located near the top of the candle

Bullish Harami Pattern
A bullish harami is formed when:
  • today's candle is white 
  • previous day's candle is dark
  • today's candle is shorter than previous


Do Candlestick Patterns Work ?

Recently, I have been exposed to a lot of material on candlestick charts (Japanese Candlestick Charting Techniques, Candlestick Forum). I really like the intuitive look and feel of a candlestick charts.

Generally speaking, quantitative trading and chart patterns do not work well together. Candlesticks make it easier. In candlestick parlance, a doji is formed when a security closes very near its open price. From a quantitative perspective, I could spot a doji as follows :




Doji as a trend reversal signal

Conventional wisdom states that the doji is a trend reversal signal. It signals a 'draw' between the buyers and sellers. If a doji shows up at end of consecutive down days, it may mean that the down trend is coming to an end.

Back testing the Idea

Let us back test this idea. I will set up my test as follows :

DataSet : SP500
BackTest Period : 15 years

Buy Signal :
Condition 1 : Look for 5 consecutive down days
Condition 2 : A doji is formed on the sixth day

Buy At Open on the seventh day

Sell Signal:
Sell on the eighth day

Buy Setup





BackTest Results
Net Profit($7,782.10)Number of Trades3,403
Profit per Bar($1.14)Average Profit($2.29)
Total Commission($13,612.00)Average Profit %0.04%
Average Bars Held2
Winning Trades1,794Losing Trades1,609
Win Rate52.72%Loss Rate47.28%
Gross Profit$152,433.90 Gross Loss($160,216.00)
Average Profit$84.97 Average Loss($99.57)
Average Profit %2.69%Average Loss %-2.92%
Average Bars Held2Average Bars Held2
Max Consecutive Winners36Max Consecutive Losses18


The theory is impressive. The name of the signal is impressive. The back test results are NOT. And this leads me to question. Do candlestick patterns work?

Performance Metrics - resonance

Recently, I blogged about Performance Metrics. My friend at Engineering Returns agrees with me.

I am not sure if the author has ranked his KPIs in ascending order of importance. But if he did, his top three metrics match with my top three.

A Price Action Based Strategy

The use of price action to make buy/sell is prevalent. According to many, price action is the fundamental thesis of practitioners of technical analysis.  Technical Analysis is the art of following price action.

I am presenting back test results for a simple price action based strategy. This is a "long-only" strategy

BUY SIGNAL
- If price goes down for three consecutive days
- If ATR (Average Trading Range) is lesser for three consecutive days

TYPICAL SETUP
A entry typical is shown below:




BACK TEST RESULTS

DataSet : SP500
Period : 15 years



Long Trades
Net Profit$18,457.37
Profit per Bar$5.41
Total Commission($6,640.00)
Number of Trades1,660
Average Profit$11.12
Average Profit %0.26%
Average Bars Held2.06
Winning Trades982
Win Rate59.16%
Gross Profit$69,689.33
Average Profit$70.97
Average Profit %1.88%
Average Bars Held1.95
Losing Trades678
Loss Rate40.84%
Gross Loss($51,231.96)
Average Loss($75.56)
Average Loss %-2.09%
Average Bars Held2.21
Maximum Drawdown($2,383.78)
Profit Factor1.36
Recovery Factor7.74
Payoff Ratio0.9


It is amazing to note a simple strategy as stated above,
- has a win rate of 60%
- is profitable over a long period of time

Performance Metrics

  "What Gets Measured Gets Done"

Over the past few weeks, I have been thinking about how to measure the success/failure of my trading strategy. I wrote a post titled, What is a good strategy. I have also been looking what other people are doing with respect to performance metrics of a strategy.

Stockalicious claims to the the Worlds Easiest Portfolio Analysis tool. It sure is easy. I uploaded my trades saved in a csv format and it gave me the following metrics

Total Return
Maximum Return
Minimum Return
Annualized Return
Volatility
Sharpe Ratio
Max DrawDown
Max Cost of Capital
Max Equity

On top of these measures, I think there are two other important measures: CAGR and Win Ratio. The Win ratio is easily calculated. It is the ratio of 



CAGR stands for Compound Annual Growth Rate. I think it gives the most accurate way of comparing two strategy by normalizing time over an year. It can be calculated as shown below



A portfolio that has a rate of return of 1% over 4 trading days has a CAGR of ~85%. Another portfolio that has a rate of return of 5% over 20 trading days also has a CAGR of ~85%. Gains of 1% over 4 days may be more achievable that gains of 5% of over a month.

Another important metric is the Max Drawdown as a measure of risk to the portfolio. This is a measure of the difference between the highest value of the portfolio to the lowest value of the portfolio. A very high drawdown can make the strategy impractical as you may not the capital to execute the on the signals provided by the strategy.

I think that these three measures (win ratio, cagr and draw down) are the most important of all the performance measures out there