doji_star() is a generic S3 function that preserves
the input class: data.frame in, data.frame out; matrix in,
matrix out.
Handling of NA values
Every indicator always emits leading NAs for the initial
lookback period - positions where there is not yet enough data to
produce a result. This is separate from how NAs already present
in the input are handled, which is controlled by the na.bridge
argument:
na.bridge = FALSE(default)The input is passed to the underlying TA-Lib C routine as-is. Because most indicators smooth across time (EMA, RSI, MACD, Bollinger Bands, ...), a single
NAin the input typically propagates forward and poisons every subsequent value - it is common for one missing observation to produce an output that is entirelyNAfrom that position onward. This mode is the right choice when you want to see the missing data in the output rather than silently compute around it.na.bridge = TRUENArows are stripped from the input before the C routine runs; the indicator is computed on the resulting dense series; results are then re-expanded to the original length withNAinserted at every position the input hadNA. Output length always matches input length, so the result can be joined back to the sourcedata.frameby row.Consequence to understand before enabling: bridging causes the indicator to treat non-consecutive observations as consecutive. A 14-period RSI with
na.bridge = TRUEover a series containing a month-long gap will compute using 14 observations that span several real-world months as if they were 14 adjacent trading days. For sparse missing values (e.g. a single missing tick) this is harmless; for clustered gaps (e.g. a delisted period, a weekend encoded asNA) the output is correctly aligned by position but economically meaningless across the gap. Inspect gap structure withwhich(is.na(x))before enabling on low-quality time series.
Arguments
- x
An OHLC-V series coercible to data.frame.
- cols
(formula). An optional
4-variable formula selecting columns fromxvia model.frame. Defaults to~open + high + low + close.- na.bridge
(logical). A logical of length 1. FALSE by default. When FALSE, input
NAs propagate through the TA-Lib C routine (most indicators will fill the remaining output withNA). When TRUE, inputNArows are stripped before computation and re-inserted at the original positions in the output, causing the indicator to treat non-consecutive non-NAobservations as if they were adjacent — see the Handling ofNAvalues section above for the consequences.- ...
Additional parameters passed into model.frame.
Value
An object of same class and length of x:
- CDLDOJISTAR
Pattern codes depend on options(talib.normalize):
If
TRUE:1= identified pattern;-1= identified bearish pattern.If
FALSE:100= identified pattern;-100= identified bearish pattern.0= no pattern.
Details
General options for candlestick pattern recognition:
- N
integer. Controls the number of candles to consider when identifying patterns.
- alpha
double. A sensitivity parameter when identifying patterns.
Available options and their defaults:
- BodyLong
(N = 10, alpha = 1.0). Real body is long when it's longer than the average of the 10 previous candles' real body.
- BodyVeryLong
(N = 10, alpha = 3.0). Real body is very long when it's longer than 3 times the average of the 10 previous candles' real body.
- BodyShort
(N = 10, alpha = 1.0). Real body is short when it's shorter than the average of the 10 previous candles' real bodies.
- BodyDoji
(N = 10, alpha = 0.1). Real body is like doji's body when it's shorter than 10% the average of the 10 previous candles' high-low range.
- ShadowLong
(N = 0, alpha = 1.0). Shadow is long when it's longer than the real body.
- ShadowVeryLong
(N = 0, alpha = 2.0). Shadow is very long when it's longer than 2 times the real body.
- ShadowShort
(N = 0, alpha = 1.0). Shadow is short when it's shorter than half the average of the 10 previous candles' sum of shadows.
- ShadowVeryShort
(N = 10, alpha = 0.1). Shadow is very short when it's shorter than 10% the average of the 10 previous candles' high-low range.
- Near
(N = 5, alpha = 0.2). When measuring distance between parts of candles or width of gaps "near" means "<=20% of the average of the 5 previous candles high low range."
- Far
(N = 5, alpha = 0.6). When measuring distance between parts of candles or width of gaps "far" means ">= 60% of the average of the 5 previous candles high-low range."
- Equal
(N = 5, alpha = 0.05). When measuring distance between parts of candles or width of gaps "equal" means "<= 5% of the average of the 5 previous candles high-low range."
The options can be modified by running options(talib.BodyLong.N = 5, talib.BodyLong.alpha = 0.2). See vignette("candlestick") for more details.
See also
Other Pattern Recognition:
abandoned_baby(),
advance_block(),
belt_hold(),
break_away(),
closing_marubozu(),
concealing_baby_swallow(),
counter_attack(),
dark_cloud_cover(),
doji(),
dragonfly_doji(),
engulfing(),
evening_doji_star(),
evening_star(),
gaps_side_white(),
gravestone_doji(),
hammer(),
hanging_man(),
harami(),
harami_cross(),
high_wave(),
hikakke(),
hikakke_mod(),
homing_pigeon(),
in_neck(),
inverted_hammer(),
kicking(),
kicking_baby_length(),
ladder_bottom(),
long_legged_doji(),
long_line(),
marubozu(),
mat_hold(),
matching_low(),
morning_doji_star(),
morning_star(),
on_neck(),
piercing(),
rickshaw_man(),
rise_fall_3_methods(),
separating_lines(),
shooting_star(),
short_line(),
spinning_top(),
stalled_pattern(),
stick_sandwich(),
takuri(),
tasuki_gap(),
three_black_crows(),
three_identical_crows(),
three_inside(),
three_line_strike(),
three_outside(),
three_stars_in_the_south(),
three_white_soldiers(),
thrusting(),
tristar(),
two_crows(),
unique_3_river(),
upside_gap_2_crows(),
xside_gap_3_methods()
Examples
## load Bitcoin (BTC)
## series
data(BTC, package = "talib")
## calculate the indicator
## for Bitcoin (BTC)
output <- talib::doji_star(BTC)
## display the results
utils::tail(output)
#> CDLDOJISTAR
#> 2024-12-26 01:00:00 0
#> 2024-12-27 01:00:00 0
#> 2024-12-28 01:00:00 0
#> 2024-12-29 01:00:00 0
#> 2024-12-30 01:00:00 0
#> 2024-12-31 01:00:00 0
## visualize the indicator
## with talib::chart()
##
## see ?talib::chart or ?talib::indicator
## for more details
{
## chart OHLC-V
## series with talib::chart()
talib::chart(BTC)
## chart indicator
## with default values
talib::indicator(
talib::doji_star
)
}
