Candlestick Patterns

Apogee Innovation Challenge –
Candlestick Pattern Identification
Ajusal Sugathan
Private & Confidential
-1-
1111077
Introduction to Candlesticks
Summer Internship
What are Candlesticks?
Candlestick charts are an excellent means to track overall market psychology.
This makes it a great tool for technical analysis!
Black or Green Bar: Close < Open => Price has gone down
White or Red Bar: Close > Open => Price has gone up
High: The top most point of the chart shows the high price
Low: The lowest point of the chart shows the low price
Open: Upper/lower point of the body based on filled/unfilled
Close: Lower/upper point of the body based on filled/unfilled
Candlesticks offer a quick picture into the psychology of short term trading, studying the
effect, not the cause! This makes them extremely useful to gauge entry and exit points.
Private & Confidential
-2-
2013
Summer Internship
2013
The Candlestick
Upper shadow signifies that the price went
higher than the actual open or close but
could not be sustained
Body signifies the actual change that
occurred between open and close
Color Code: Black or Red for down move
(close < open) and White or Green for up
move (close > open)
Lower shadow signifies that the price went
below the actual close or open but couldn't
sustain at that level
Private & Confidential
-3-
Understanding the paradigm
Summer Internship
Building the alphabet
Every candle corresponds to a period of 1 minute. Open, High, Low and Close prices from
every minute are used to build a candle each.
Every candle is to be considered as a letter of the alphabet.
Just like any language has different letters, similarly we have different types of candles in
our language
Examples of different
letters of the alphabet
Private & Confidential
-4-
2013
Alphabets to Words
Alphabets combine to build words
In any language, letters combine to form different words of
varying lengths. Similarly here, candles together form
candlestick patterns of varying lengths.
Private & Confidential
-5-
Summer Internship
2013
Summer Internship
2013
Types of Candlestick Patterns
Candlestick Patterns
One Candle Patterns
One letter words
Two Candle Patterns
Three Candle Patterns
Two letter words
Three letter words
For a detailed discussion on candlestick patterns see Appendix
Private & Confidential
-6-
1 trading day = 1 sentence
Summer Internship
Each trading day is one sentence.
Every trading day consists of several words.
A typical trading day on the National Stock Exchange (NSE) is for 375 minutes.
Thus, one day’s price for NIFTY Index can be represented by
an array of 375 candles.
Some of these 375 alphabets will form meaningful words (i.e., candlestick patterns).
Thus, a trading session will have multiple words, which together form
one sentence per trading day.
Private & Confidential
-7-
2013
Example of a sentence
Summer Internship
The stock price of Apple Inc, showing multiple words being formed through the day (a sentence)
Private & Confidential
-8-
2013
Problem Statement
Summer Internship
2013
Write a program in a language of your choice, to identify as many
candlestick patterns as you can, given the price data for 1 trading day
INPUT: 375 rows where each row contains 4 comma separated values –
<Open,High,Low,Close> prices corresponding to every minute of trading.
OUTPUT: A list of all patterns found in that day’s candlestick chart in the following format:
<candle_number,pattern_name>
Where candle_number is the candlestick number where the pattern begins.
The output should have one line for every pattern identified.
Try to identify as many patterns as you can.
An exhaustive list of patterns that you may identify is available at: http://bit.ly/1mHoQ5q
Credit will be given to correct pattern identification and number of patterns identified.
For sample input and output visit:
http://www.hedgequants.com/apogee/aic
Private & Confidential
-9-
Summer Internship
2013
Appendix
For illustration only
Private & Confidential
- 10 -
Appendix
Summer Internship
2013
Candlestick Patterns
One Candle Patterns
 Also known as umbrella patterns
 They have long lower shadows and
short real bodies
 Eg: Hammer, Hanging man etc.
Two Candle Patterns
Three Candle Patterns
 2 candle formations that indicate
some kind of trend or reversal
 3 candle formations that generally
indicate reversals
 Eg: Bullish engulfing, Bullish
harami etc.
 Eg: Evening star, morning star etc.
Private & Confidential
- 11 -
Summer Internship
2013
The Hammer
Type of Pattern
Time Frame
Indication
One Candle Pattern
Daily Candlesticks
Reversal to an uptrend
Criteria:
1.
Lower shadow greater than or equal to 2 x length of body
2.
There should be no or very small upper shadow
3.
If the candle has white body (up move) = Slightly more
bullish indication
4.
If next day is bullish, it is additional conformation
Logical Interpretation:

Market has been on a downtrend, hence it opens and trades lower due to the bearish outlook

But, now the bulls step in and market returns to a high for the day, thus a small body & large shadow

This shows that the bears couldn't maintain control and they start questioning that will the trend continue

Many of the bears will turn bulls once they get a confirmation of higher open and higher close next day
Private & Confidential
- 12 -
Summer Internship
2013
Hanging Man
Type of Pattern
Time Frame
Indication
One Candle Pattern
Daily Candlesticks
Reversal to a downtrend
Criteria:
1.
Lower shadow greater than or equal to 2 x length of body
2.
There should be no or very small upper shadow
3.
If the candle has black body (down move) = Slightly more
bearish indication
4.
If next day is bearish, it is additional conformation
Logical Interpretation:

Market has been on an uptrend, hence it opens high due to the bullish outlook

But as the bears have started selling now, there is a significant sell-off near the market open

Although, buyers are able to push this stock back up so that it closes at or near the opening price

Generally the large sell-off is seen as an early indication that the bulls (buyers) are losing control
Private & Confidential
- 13 -
Summer Internship
2013
Inverted Hammer
Type of Pattern
Time Frame
Indication
One Candle Pattern
Daily Candlesticks
Reversal to an uptrend
Criteria:
1.
Upper shadow greater than or equal to 2 x length of body
2.
There should be no or very small lower shadow
3.
If the candle has white body (up move) = Slightly more
bullish indication
4.
If next day is bullish, it is additional conformation
Logical Interpretation:

Market has been on a downtrend, hence it opens low due to the bearish outlook

But as the bears have started buying now, there is a significant buying near the market open

Although, sellers are able to push this stock back down so that it closes at or near the opening price

Generally the large buying is seen as an early indication that the bears (sellers) are losing control
Private & Confidential
- 14 -
Summer Internship
2013
Shooting Star
Type of Pattern
Time Frame
Indication
One Candle Pattern
Daily Candlesticks
Reversal to a downtrend
Criteria:
1.
Upper shadow greater than or equal to 2 x length of body
2.
There should be no or very small lower shadow
3.
If the candle has black body (down move) = Slightly more
bearish indication
4.
If next day is bearish, it is additional conformation
Logical Interpretation:

Market has been on an uptrend, hence it opens high and trades higher due to the bullish outlook

But, now the bears step in and market returns to a low for the day, thus a small body & large shadow

This shows that the bulls couldn't maintain control and they start questioning that will the trend continue

Many of the bulls will turn bears once they get a confirmation of lower open and lower close next day
Private & Confidential
- 15 -
Summer Internship
2013
Doji
Type of Pattern
Time Frame
Indication
One Candle Pattern
Daily Candlesticks
Trend Reversal
Criteria:
1.
A doji candlestick has open almost equal to the close
2.
It is a sign of indecision and trend reversal
3.
It is significant only in markets where there are not many dojis occurring
across days
4.
A doji should be taken as a warning sign for people riding on a trend
Logical Interpretation:

A doji indicates a balance between demand and supply or buying and selling forces

It should be considered a warning signal especially for an uptrend

In down trends the market may still fall due to high volatility during down times

Hence, we need confirmation the next day to indicate a reversal from a downtrend
Private & Confidential
- 16 -
Summer Internship
2013
One candle patterns in action
Private & Confidential
- 17 -
Summer Internship
2013
Bullish Engulfing Pattern
Type of Pattern
Time Frame
Indication
Two Candle Pattern
Daily Candlesticks
Reversal to an uptrend
Criteria:
1.
Large white real body completely eclipses or engulfs a small black
real body
2.
The white candlestick opens lower than or equal to previous days
close and closes higher than previous days open
3.
The color of the candlestick preceding the black candlestick should also
be black (continual of down move)
4.
The indication is even stronger if the engulfing white body completely
eclipses the complete previous candlestick including shadows
Logical Interpretation:

After a continual declining trend the price opens lower due to the bearish sentiment in the market

But, before the close of the day buyers have taken over and pushed the price above the previous open

This shows that the market sentiment has changed and there is high probability of a bull run occurring
Private & Confidential
- 18 -
Summer Internship
2013
Bearish Engulfing Pattern
Type of Pattern
Time Frame
Indication
Two Candle Pattern
Daily Candlesticks
Reversal to a downtrend
Criteria:
1.
Large black real body completely eclipses or engulfs a small white
real body with short shadows
2.
The black candlestick opens higher than or equal to previous days
close and closes lower than previous days open
3.
The color of the candlestick preceding the white candlestick should also
be white(continual of up move)
4.
The indication is even stronger if the engulfing black body completely
eclipses the complete previous candlestick including shadows
Logical Interpretation:

After a continual up trend the price opens higher due to the bullish sentiment in the market

But, before the close of the day sellers have taken over and pushed the price below the previous open

This shows that the market sentiment has changed and there is high probability of a bear run occurring
Private & Confidential
- 19 -
Summer Internship
2013
Piercing Pattern
Type of Pattern
Time Frame
Indication
Two Candle Pattern
Daily Candlesticks
Reversal to an uptrend
Criteria:
1.
A long black candle appears at the end of a down trend followed by a
white candle which closes more than half way up the black candle
2.
The white candle day has an open which is lower than the close of the
black candle day
3.
The signal is stronger if the difference between black candle close and
white candle open is more
4.
Lesser the difference between black candle open and white candle
close, stronger the signal
Logical Interpretation:

After a continual down trend the price opens lower due to the bearish sentiment in the market

As the day progresses the bulls enter and push the price back up near the previous days high

The bulls have almost negated the huge price decline that happened the previous day

More buying on the next day would confirm the bullish signal for a strong uptrend
Private & Confidential
- 20 -
Summer Internship
2013
Bearish Harami
Type of Pattern
Time Frame
Indication
Two Candle Pattern
Daily Candlesticks
End of up-trend
Criteria:
1.
A large white body at the end of an uptrend, followed by a black body
that is totally within the previous white body
2.
The black candle opens lower than the white candle’s close, and
closes higher than the white candle’s open
3.
Reversal is possible, but the immediate expectation is that of a period of
consolidation
Logical Interpretation:

After a prolonged uptrend the bears open the market at a price lower than the previous close

Due to this the bulls get concerned and start profit taking and hence price end even lower

A non-trending or bearish day after this would lead most of the bulls to start selling leading to either a
consolidation or reversal
Private & Confidential
- 21 -
Summer Internship
2013
Bullish Harami
Type of Pattern
Time Frame
Indication
Two Candle Pattern
Daily Candlesticks
End of down-trend
Criteria:
1.
A large black body at the end of a downtrend, followed by a white body
that is totally within the previous black body
2.
The white candle opens higher than the black candle’s close, and
closes lower than the black candle’s open
3.
Reversal is possible, but the immediate expectation is that of a period of
consolidation
Logical Interpretation:

After a prolonged downtrend the bulls open the market at a price higher than the previous close

Due to this the bears get concerned and start covering their short positions and hence price ends even higher

A non-trending or bullish day after this would lead most of the bears to start covering short position leading to
either a consolidation or reversal
Private & Confidential
- 22 -
Summer Internship
2013
Two candle patterns in action
Private & Confidential
- 23 -
Summer Internship
2013
Evening Star
Type of Pattern
Time Frame
Indication
Three Candle Pattern
Daily Candlesticks
Reversal to a downtrend
Criteria:
1.
The 1st candle should be white ending a sustained uptrend
2.
The 2nd candle has a small trading range that depicts indecision
3.
The 3rd candle should be black to show the beginning of downtrend
4.
If there is a gap opening for 2nd and 3rd candle, the indication is stronger
5.
The more longer the 1st and 3rd candle and the more shorter the 2nd
candle, the more stronger the indication
Logical Interpretation:

1st Candle: A prolonged uptrend has been in effect thus leading to a tall white candle

2nd Candle: Now some of the bulls start taking profits or think its fairly valued leading to all buying
being equalized by selling, leading to a small trading range

3rd Candle: Now the bulls get skeptical and realize that the trend is reversing and start selling leading to a
potential downtrend
Private & Confidential
- 24 -
Summer Internship
2013
Morning Star
Type of Pattern
Time Frame
Indication
Three Candle Pattern
Daily Candlesticks
Reversal to an uptrend
Criteria:
1.
The 1st candle should be black ending a sustained downtrend
2.
The 2nd candle has a small trading range that depicts indecision
3.
The 3rd candle should be white to show the beginning of uptrend
4.
If there is a gap opening for 2nd and 3rd candle, the indication is stronger
5.
The more longer the 1st and 3rd candle and the more shorter the 2nd
candle, the more stronger the indication
Logical Interpretation:

1st Candle: A prolonged downtrend has been in effect thus leading to a tall black candle

2nd Candle: Now some of the bears start taking profits or think its fairly valued and all buying gets
equalized by selling, leading to a small trading range

3rd Candle: Now the bears get skeptical and realize that the trend is reversing and start selling leading to
a potential uptrend
Private & Confidential
- 25 -
Summer Internship
2013
Three candle patterns in action
Private & Confidential
- 26 -
About Us
Summer Internship
2013
Who are we?
We are an alternative investment management firm having a strong investor backing
constantly striving to deliver performance that is both significant and consistent,
maximizing investment returns while protecting capital. In pursuit of that goal, we
employ a variety of quantitative investment strategies coupled with risk management
strategies that help to mitigate risk as well as maximize alpha.
What do we do?
At Hedge Quants, we believe that the future of trading and investment lies in
quantitative models and automation and it is in this very domain that we strive to
become the market leaders. In order to achieve this we strive daily to build quantitative
models and systems for our unique trading strategies that have the potential to beat
the market consistently.
Our Work Culture
Hedge Quants has a relaxed workplace coupled with an intellectually stimulating
environment. We put a premium on quality of life. By working intelligently and
efficiently, there is time to enjoy life. Our office is an open workplace that involves
everyone in what is happening in the business. The goal is for everyone to be excited,
happy, and challenged, and to have the opportunity to live up to their potential.
HQ Capital Advisory, LLP
230/B, AJC Bose Road,
2nd Floor, Opp Minto Park,
Kolkata – 700020
E-mail: [email protected]
Phone: +91 8017255625
www.hedgequants.com
Private & Confidential
- 27 -