• : Prashant Shah
Back-testing of Engulfing candlestick pattern on daily charts of Indian markets

Engulfing is a very popular candlestick pattern. Below is an image explaining it.

eng

For an engulfing pattern, it is important that body of the second candle engulfs body of previous candle. Shadows need not be engulfed.

In this post, we wanted to back-test the occurrence and significance of this candlestick pattern in Indian markets. Engulfing pattern gets qualified at closing price of second candle. So, the closing price has been considered as the entry price for back-testing exercise.
For testing, it is important to decide the exit strategy. There can typically be two types of exits: First, when pattern gets failed and the second, while taking profit

Below is a condition of pattern failure.

Eng

In simple words, Bullish engulfing gets negated if the price falls below the lowest price of two candles that form the Bullish engulfing pattern. Similarly, a bearish engulfing pattern gets negated when price moves above the highest price of two candles forming part of the bearish engulfing pattern.

While the initial exit or pattern invalidation criteria is plain and simple, there can be numerous methods of profit taking.

Here are the details of the testing parameters
Occurrence: Number of times pattern has occurred. It can vary as per the exit criteria defined.
Average return: Gain or loss generated per occurrence.
Risk–reward ratio: Average profit of all successful trades divided by average loss of all failed trades. It shows the reward generated against the risk of 1 point or 1-rupee.
Success ratio: Ratio of occurrences that resulted in a positive outcome.
Expectancy: While performing tests on pattern occurrence, success rate alone is not sufficient to evaluate. A pattern can have lesser winning rate but be more rewarding over a period due to higher risk–reward rate. Hence, outcomes must be evaluated based on expectancy; its formula is as follows:
Expectancy: (Success Ratio x Risk–Reward Ratio) - Failure Ratio
The failure ratio is the percentage of occurrences that resulted in negative outcome.
 
Expectancy basically indicates whether a strategy is profitable or not. Positive expectancy helps in identifying a strategy that can be confidently executed, going forward.
 
A period of more than 22 years starting from 1st Jan 1996 to 16th March 2018 or listing date, whichever is earlier, is considered for testing the pattern. Performance of Bullish and Bearish patterns are shown separately so that both can be analyzed independently. Note that open trades are not considered for tests.

Before we begin, let me make it clear that I know that engulfing is a reversal pattern and pattern in the direction of the trend is known as last engulfing etc. But let’s begin with the idea of testing the occurrence of engulfing formation.

Below is the table showing the back-testing results of the Engulfing patterns on the daily candlestick chart of Nifty and Bank Nifty.  The exit criterion for booking the profits is considered as 1.5% gain. To put it in simple words, the entry is at the closing price when engulfing pattern gets qualified and the stop loss is at the lowest price of last two candles if it is a bullish pattern and highest price of last two candles if it is a bearish pattern. Profit booking is considered if there is a 1.5% move in our favour after the entry.

Table 1:

Back-testing of Engulfing pattern
Instruments: Nifty and Bank Nifty
Period: Since inception to 16th March 2018.
Entry criterion: Engulfing pattern
Exit criterion: pattern failure or 1.50% move in favour to book profit. 

1

Table says, 55% - 57% is a hit ratio of the pattern for above mentioned conditions. But Risk-reward is not very encouraging. Meaning, the losses that are booked when pattern gets failed are high. Expectancy is not too encouraging either.
But, a few of the readers may wonder why take profits at 1.5% move? That is a valid question and the basic idea here is to begin with some number.  I haven’t optimised it and I don’t believe in optimising either.

Let’s consider the same experiment but the only tweak is the profit-taking criteria which is changed to 0.5% instead of 1.5%
Here are the results of the back-test based on revised profit-taking criteria:

Table 2:

Back-testing of Engulfing pattern
Instruments: Nifty and Bank Nifty
Period: Since inception to 16th March 2018.
Entry criterion: Engulfing pattern
Exit criterion: pattern failure or 0.50% move in favour to book profit. 

2

Table shows huge improvement in the success ratio, but hardly any improvement in the risk reward or expectancy. Meaning, there is better probability with 0.50% exit rule, but you are unlikely to make any significant money.

Let’s test the pattern based on the risk-reward criteria. The risk is the difference between the entry price and the pattern failure level. So If I am taking X amount of risk, I must get better than that to stay profitable. Let’s begin with a risk-reward of 1:3. The table below captures the back-testing results based on the 1:3 risk-reward exit criteria.

Table 3:

Back-testing of Engulfing pattern
Instruments: Nifty and Bank Nifty
Period: Since inception to 16th March 2018.
Entry criterion: Engulfing pattern
Exit criterion: pattern failure or 1:3 RR criterion to book profit. 

3

Success rate is low, but Risk reward ratio is much better and expectancy is positive. Let’s test the pattern with a 1:2 risk-reward criteria.

Table 4:

Back-testing of Engulfing pattern
Instruments: Nifty and Bank Nifty
Period: Since inception to 16th March 2018.
Entry criterion: Engulfing pattern
Exit criterion: pattern failure or 1:2 RR criterion to book profit. 

4

Overall Risk-reward and expectancy improved. 

This was just an attempt to get an idea about probabilities of a move just based on engulfing pattern.  How about an idea of infusing trend element in this? Let me use a very basic indicator, 10 day simple moving average for infusing trend. So, engulfing pattern occurring above moving average is pattern in direction of trend and it is occurring below average is pattern occurred against the trend. We can test these occurrences separately. Below is a table showing performance of engulfing pattern when they are above or below moving average.

Table 5:

Back-testing of Engulfing pattern
Instruments: Nifty and Bank Nifty
Period: Since inception to 16th March 2018.
Entry criterion: Bullish engulfing pattern above SMA and bearish engulfing pattern below SMA.
Exit criterion: pattern failure or 1:1.50 RR criterion to book profit. 

5

Numbers are improved when pattern is seen in direction of the trend. Let’s see how it looks against the trend. Below is a table showing performance of pattern when it is occurred against the average line.

Table 6:

Back-testing of Engulfing pattern
Instruments: Nifty and Bank Nifty
Period: Since inception to 16th March 2018.
Entry criterion: Bullish engulfing pattern below SMA and bearish engulfing pattern above SMA.
Exit criterion: pattern failure or 1:1.50 RR criterion to book profit. 

6

How about testing this pattern on individual stocks? Below is a table showing the results of engulfing pattern in the universe of 500 stocks forming part of the Nifty-500 index. It is the largest group available in National Stock Exchange and includes stocks from a variety of groups. It offers a sufficiently large and diverse sample size. Resulting numbers are average of all the occurrences.

Table 7:

Back-testing of Engulfing pattern
Instruments: Nifty 500
Period: From 1st Jan 1996 to 16th March 2018.
Entry criterion: Engulfing pattern
Exit criterion: pattern failure or 1:2 RR criteria to book profit. 

7

Below are the tables showing performance of pattern when tested in direction or against the trend.

Table 8:

Back-testing of Engulfing pattern
Instruments: Nifty 500
Period: From 1st Jan 1996 to 16th March 2018.
Entry criterion: Bullish engulfing pattern above SMA and bearish engulfing pattern below SMA.
Exit criterion: pattern failure or 1:2 RR criterion to book profit. 

8

Table 9:

Back-testing of Engulfing pattern
Instruments: Nifty 500
Period: From 1st Jan 1996 to 16th March 2018.
Entry criterion: Bullish engulfing pattern below SMA and bearish engulfing pattern above SMA.
Exit criterion: pattern failure or 1:2 RR criterion to book profit. 

9

Note that while calculating average of RR, I have calculated total profit and loss which is a correct method to calculate average numbers. The exercise here is to test the performance of patterns. These are not trading systems per se; hence, slippages or any other charges are not considered while testing, so the numbers are gross.

This was an attempt to check performance of last occurrences and probability of move post the occurrence. Rules stated above alone may not sufficient to take trades, but the knowledge of the performance of the patterns might help you while considering the pattern in your setup or while using it with some other tool or indicator.

Next day opening can provide confirmation to an engulfing pattern. Such type of filtrations might improve the overall results.The study of the above tables might help those who trade these price patterns.

Remember, back-testing is certainly important, but it doesn’t guarantee anything. It’s a tool to understand the pattern or instrument; and its behavior during different market phases. Learning should be generic. It appears from the test results that long setups work well and the performance of Bearish patterns is comparatively unimpressive may be because the overall trend has been bullish in Indian markets. It appears that performance of patterns improves when they are used in direction of the trend.
 
Also note, that appearance of bearish pattern is more than the bullish pattern though market has been in the uptrend for most of the time during the sample period. Meaning, you keep getting bearish patterns against the major trend but you need more evidence to act based on it.
 
You can also back-test occurrence of engulfing in any stock to check the probability of move post that pattern and to check whether it suits the behaviour of that particular instrument.
How about trading failure of the engulfing pattern? And how is the performance on weekly or monthly charts? Those are interesting topics for sure and would be addressed in subsequent posts. I will soon share study of other candlestick patterns in this manner.
 
Note: The back-test discussed above was performed in the TradePoint software.  
 
Please direct your feedback or suggestions to prashant.shah@definedge.com