Doji Star (CDLDOJISTAR)
Summary
A two-candle reversal pattern: a long real body followed by a doji whose real body gaps away from it (up after a white body, down after a black body). Signals a potential reversal of the prevailing trend. A hit flags a likely trend reversal; true direction depends on the prevailing trend (bullish in a downtrend, bearish in an uptrend), which the code does not itself verify.
Chart
Chart metadata i
Outputs
outInteger:pattern_bull_bear·zero·positive·negative
Formula
Two candles. Candle 1: long real body (realbody > BodyLong average). Candle 2: doji (realbody <= BodyDoji average). Gap: either candle 1 white (color1) AND candle 2 real body gaps up above it (the real bodies gap up), or candle 1 black (color-1) AND candle 2 real body gaps down below it (the real bodies gap down).
Notes
- Does not verify the prior trend the reversal signal classically assumes.
- Bulkowski's testing contradicts the classic reading for the bullish case: theory says a bullish Doji Star (gapping down after a black candle) should be a bullish reversal, but he found it instead acts as a bearish CONTINUATION 64% of the time — almost 2 out of 3, the opposite of the textbook signal. (thepatternsite.com)
Inputs
inOpen— Open price of each barinHigh— High price of each barinLow— Low price of each barinClose— Close price of each bar
Outputs
outInteger— Emits +100 or -100 on a hit, 0 otherwise. Value is -candlecolor(candle1)*100: -100 when candle 1 is white (gap up), +100 when candle 1 is black (gap down)
Output Values
What candlestick values mean: Candlestick Outputs. The function's flags declare which values it can return: rW7.
| Value | Meaning |
|---|---|
| -100 | Doji Star gapping up after a strong advance — waning momentum, a bearish warning if it appears in an uptrend |
| 0 | No pattern |
| 100 | Doji Star gapping down after a strong decline — waning momentum, a bullish warning if it appears in a downtrend |
Properties
Numerical Stability: Start-Independent
| ☐ Overlap Input |
| ✅ Independent Y-Axis i |
| ✅ Candlestick i |
| ☐ Display Shift |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ☐ Uses Transcendental |
| ☐ Input Must Be Positive |
Example
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double open[252]; /* your data, oldest first */
double high[252]; /* your data, oldest first */
double low[252]; /* your data, oldest first */
double close[252]; /* your data, oldest first */
int out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_CDLDOJISTAR( 0, n - 1, open, high, low, close, &outBegIdx, &outNBElement, out );
printf( "%d values from bar %d; last out = %d\n", outNBElement, outBegIdx, out[outNBElement - 1] );use ta_lib::Core;
let open = vec![0.0; 252]; // your data, oldest first
let high = vec![0.0; 252]; // your data, oldest first
let low = vec![0.0; 252]; // your data, oldest first
let close = vec![0.0; 252]; // your data, oldest first
let mut out = vec![0i32; 252];
let core = Core::new();
let range = core.cdldojistar(0, open.len() - 1, &open, &high, &low, &close, &mut out)?;
println!("{} values from bar {}; last out = {}", range.count, range.beg_idx, out[range.count - 1]);import io.github.talib.Core;
import io.github.talib.OutRange;
double[] open = new double[252]; // your data, oldest first
double[] high = new double[252]; // your data, oldest first
double[] low = new double[252]; // your data, oldest first
double[] close = new double[252]; // your data, oldest first
int[] out = new int[252];
Core core = Core.DEFAULT;
OutRange r = core.cdldojistar(0, open.length - 1, open, high, low, close, out);
System.out.println(r.count() + " values from bar " + r.begIdx() + "; last out = " + out[r.count() - 1]);using System;
using TALib;
var open = new double[252]; // your data, oldest first
var high = new double[252]; // your data, oldest first
var low = new double[252]; // your data, oldest first
var close = new double[252]; // your data, oldest first
var outInteger = new int[252];
var core = Core.Default;
OutRange r = core.Cdldojistar(0, open.Length - 1, open, high, low, close, outInteger);
Console.WriteLine($"{r.Count} values from bar {r.BegIdx}; last outInteger = {outInteger[r.Count - 1]}");import { cdldojistar } from 'ta-lib';
const open = new Float64Array(252); // your data, oldest first
const high = new Float64Array(252); // your data, oldest first
const low = new Float64Array(252); // your data, oldest first
const close = new Float64Array(252); // your data, oldest first
const { begIdx, values } = cdldojistar({ open, high, low, close });
console.log(values.length + ' values from bar ' + begIdx + '; last values = ' + values[values.length - 1]);Implementation
Added in 0.4.0.
TA-Lib Definition: cdldojistar.c · cdldojistar.yaml
| Native | File |
|---|---|
| C | ta_CDLDOJISTAR.c |
| Rust | cdldojistar.rs |
| Java | Core_CDLDOJISTAR.java |
| C# | Core_CDLDOJISTAR.cs |
| TypeScript | cdldojistar.ts |
Python: talib.CDLDOJISTAR, see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
Doji Star
See Also
CDLMORNINGDOJISTAR · CDLEVENINGDOJISTAR · CDLDOJI · CDLMORNINGSTAR · CDLEVENINGSTAR