HAMMER PATTERNS
The
hammer pattern may mark a reversal of a stock’s downtrend. Hammers have long
lower shadows or tails, short or no upper shadows, and small bodies. They
actually look like a hammer, with the long tail being the handle and the small
body being the head of the hammer. The color of the body is not considered
important; it can be either a white or black body, implying the hammer can
occur on either an up or down day.
The
most common definition requires the lower shadow to be twice the length of the
body, or more. The common definitions indicate there should be no or very
little upper shadow showing and the day’s high should be near the close for a
white body and near the open for a black body. One of the advantages of
backtesting a potential trading pattern is that we can investigate this
definition and determine things like whether the color of the body matters,
whether different lengths of the lower shadow affect results, and just how
small the upper shadow has to be.
Figure 4.1 shows a hammer pattern in EXBD
that occurred on 07/14/06 and is marked by the down arrow on the chart. EXBD
had been in a clear downtrend, as marked by a series of lower highs and lower
lows, for 10 weeks. On 07/14/06, the stock moved down after the open, which is
the bottom of the body on a white candlestick, and then retraced the move to
close up for the day. This trading action left a long lower shadow, which is
more than twice the length of the body, and a small upper shadow that completed
the definition of a hammer pattern. After forming the hammer pattern, EXBD
moved up more than $3 in the next few trading sessions.
FIGURE 4.1: HAMMER PATTERN IN EXBD ON 7/14/06
Hammers
can also have a black body, indicating they closed down for the day. The only
requirements are a small upper shadow and a lower shadow that is more than
twice the length of the body. Figure 4.2 shows
a black-bodied hammer that occurred in PHI on 06/28/06 and is marked by the up
arrow on the chart.
FIGURE 4.2: HAMMER PATTERN IN PHI ON 6/28/06
Courtesy of AIQ
PHI
had been in a downtrend for two months when, on 06/28/ 06, it opened down and
continued moving down. Later in the day, it rallied and closed near the highs
of the day, forming a long lower shadow and a black body. During the next four
trading sessions, PHI ran up over 13%.
DETERMINING THE
OPTIMAL PATTERN DEFINITION-SHADOWS
The
requirement in the hammer definition that the pattern have a small or no upper
shadow is not well defined. In order to backtest the pattern, we need a
specific definition. I chose to start with the requirement that the upper
shadow be less than 15% of the day’s trading range. The good thing about
backtesting is that we can easily test a range of lengths for the upper shadow
to determine if it makes a significant difference, and if it does, we can then
determine which is the best one to use.
INITIAL TEST PERIOD:
1/3/06 to 5/1/07
Figure 4.3 shows a hammer with a large upper
shadow (marked by the down arrow) that occurred in ZF on 04/18/05. In order to
determine if larger upper shadows affect the trading results of the hammer
pattern, we can use backtesting techniques.
FIGURE 4.3: HAMMER WITH LARGE UPPER SHADOW IN
ZF ON 4/18/05
The
backtest results of Figure 4.4 were obtained
by looking at all the hammers that occurred in downtrending stocks during the
period of 01/03/06 to 05/01/07. When a hammer pattern formed, a trade was
entered the next day at the opening price, held for five days, and sold. The
tests were run on a database of about 2,200 stocks that comprise trading
candidates that have an average daily volume greater than 200,000 shares plus
most of the sector ETFs. This is the database from which I trade. A stock with
lower average daily volumes may have wide bid/ask spreads and can be hard to
enter and exit quickly.
FIGURE 4.4: INITIAL BACKTEST OF HAMMER
PATTERN
Figure 4.4 indicates that hammer patterns
occur quite frequently since the backtest took more than 3,800 positions during
the 1/2-year test period. The basic pattern shows an annualized ROI of slightly
over 10%. This sounds interesting until you notice that the annualized ROI for
trading the SPX during the same period was slightly over 14%. Our first pass
indicated that during this test period the hammer pattern, as defined, is not
something I would trade. However, backtesting techniques allow us to explore
how this pattern works in different market conditions and also if changes in
the basic definition would improve results.
The
hammer definition does not clearly define what “little
or no” upper shadow means, so that is a reasonable place to begin our
investigation of the pattern. The test results of Figure
4.4 used a requirement that the upper shadow be less than 15% of the
day’s trading range. Examining the results of testing different upper shadow
length requirements will help us understand what works best.
One
of the important aspects of trading patterns is to make sure they are clearly
defined. When a pattern definition contains adjectives such as big or small, it
leaves room for interpretation in the definition. When there is room for
interpretation, traders using the same pattern may see different results due to
the interpretation issues.
DIFFERENT UPPER
SHADOW LENGTHS
Table 4.1 shows the effect of different upper
shadow lengths on the test results of the hammer pattern during the 01/03/06 to
05/01/07 testing period. For this particular test period, it appears that
reducing the upper shadow length reduces annualized ROI. Rather than requiring
the hammer pattern to have little or no upper shadow, the results of Table 4.1 indicate we should consider hammers
whose upper shadow length is 20% or less of the day’s trading range.
TABLE 4.1 EFFECT OF UPPER SHADOW LENGTH ON
HAMMER RESULTS DURING 1/03/06 TO 5/01/07
Since
the initial results indicate that shorter upper shadows actually reduce returns
of the hammer pattern and since this result was unexpected, I decided to run
the tests in a different time period. I also ran a test that was twice as long.
If results are similar in different time periods, they are more likely to be
correct.
Table 4.2 shows the results of testing the
hammer pattern during the three-year period of 01/01/04 to 12/29/06. This data
leads to several interesting conclusions. First, since the number of trades
increased in rough proportion to the increase in the testing time frame, it
would appear that hammer patterns are a regular occurrence through different
time frames and market conditions. This is a positive result, since patterns
that occur infrequently or are found only in one time frame may be event-driven
rather than a natural part of market activity.
TABLE 4.2 EFFECT OF UPPER SHADOW LENGTH ON
HAMMER RESULTS DURING 1/01/04 TO 12/29/06
The
second interesting result of comparing the data in Table
4.1 and 4.2 is that the annualized ROIs were similar. This indicates
that in different time periods and market conditions, the pattern performs
about the same. This gives confidence that the returns are not driven by
specific things that just occurred in one time frame and hence may not repeat
in the future.
The
third interesting result of comparing the data in Table
4.1 and 4.2 is that in both test periods the annualized ROI decreased
consistently as the upper shadow length was decreased. This lends credibility
to the thought that when using hammer patterns, we should allow upper shadow
lengths of up to 20% of the day’s trading range.
Since
the data in Tables 4.1 and 4.2 indicate that the annualized ROI decreases as
the upper shadow length requirement decreases, it raises an interesting question.
What happens if we require hammer patterns to have an upper shadow length of at
least 5% of the day’s range, and less than 20% of the day’s range? This test
result is shown in Figure 4.5.
FIGURE 4.5: HAMMER BACKTEST WITH UPPER SHADOW
>5% AND <20% OF DAY’S RANGE
UPPER SHADOWS
BETWEEN 4 AND 20%
Figure 4.5 indicates that testing the hammer
during the three-year period of 2004, 2005, and 2006 shows improved results by
adding a requirement that the upper shadow in the pattern be between 4% and 20%
of the day’s trading range. This new requirement filters out hammer patterns
with small upper shadows between 0 and 4% of the day’s trading range. It
improves the annualized ROI as compared to just a requirement that the upper
shadow be less than 20% of the day’s trading range. It appears that the hammer
pattern works best with at least a small upper shadow.