Chapter 6 Candle Stick Pattern
In this chapter, we learn how to use R to detect the following candle stick patterns.
Learning Objectives:
- 1-day patterns:
- doji
- hammer
- 2-day patterns:
- engulfing
- harami
- median reversal
- two in a row (kicking)
- 3-day patterns:
- three-in-a-row
- star
- 5-day pattern:
- three method
Throughout this chapter, we use Microsoft (ticker: MSFT) to do demonstration
To make our code more compact, let us define the following:
OP <- as.numeric(Op(MSFT))
LO <- as.numeric(Lo(MSFT))
HI <- as.numeric(Hi(MSFT))
CL <- as.numeric(Cl(MSFT))
N <- nrow(MSFT)
We have used as.numeric to take out the timestamp of the xts data for comparsion.