6.1 Basis of candle stick
Candle Sticks make uses of all four daily prices series: high, low, open, close
For a candle sticks, its two ends are high and low prices while two ends of its (real ) body are close and open prices.
Color is important for a candle stick. A candle is a bullish candle if the close > open. A bullish candle is either green or white. A candel is a bearish candle if close < open. A bearish candel is either red or black.
The median of a candle stick is average of closign and opening price:
\[M(t) = \frac{Op(t)+Cl(t)}{2}\]
There are four important lengths for a candle stick:
- upper shadow
- lower shadow
- whole candle length
- body length
The upper shadow is line between high and real body while the lower shadow is line between low and real body. Hence, upper shadow length is
\[US(t)=Hi(t)-\max\{Op(t),Cl(t)\}\]
Similarly, lower shadow length is
\[LS(t)=\min\{Op(t),Cl(t)\}-Lo(t)\]
Whole candle length is
\[WC(t)=Hi(t)-Lo(t)\]
Body length is
\[BL(t)= |Op(t)-Cl(t)|\]
6.1.1 Remark: More compact code
We have used for loop to do the job but it can be done more elegant way through vector operations:
Note that this vectorized operation would inherit the time series property (i.e., with timestamp). Note that pmax() is to return a vector that gives maximum number for each element in a vector. It is similar for pmin().