Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ta4j/ta4j/llms.txt

Use this file to discover all available pages before exploring further.

Candlestick pattern indicators extend CachedIndicator<Boolean> and return true when the pattern is detected at a given index, false otherwise. They return false during the warm-up period — never NaN. Most accept a BarSeries constructor and expose tunable thresholds via an overloaded constructor. Pattern indicators compose naturally with Rule objects:
BullishEngulfingIndicator engulfing = new BullishEngulfingIndicator(series);
Rule entry = new BooleanIndicatorRule(engulfing);

Helper indicators

Two helper indicators power many pattern checks internally and can be used directly:
ClassConstructorReturns
RealBodyIndicatorRealBodyIndicator(BarSeries)close - open (positive = bullish)
UpperShadowIndicatorUpperShadowIndicator(BarSeries)high - max(open, close)
LowerShadowIndicatorLowerShadowIndicator(BarSeries)min(open, close) - low
RealBodyIndicator   body        = new RealBodyIndicator(series);
UpperShadowIndicator upperWick  = new UpperShadowIndicator(series);
LowerShadowIndicator lowerWick  = new LowerShadowIndicator(series);

Bullish patterns

Constructors:
  • HammerIndicator(BarSeries series) — default ratios: body-to-lower-wick ≥ 2, body-to-upper-wick ≤ 1
  • HammerIndicator(BarSeries series, double bodyToBottomWickRatio, double bodyToUpperWickRatio)
Single-candle bullish reversal pattern in a downtrend: small body at the top, long lower shadow at least twice the body, tiny or absent upper shadow. Signals that sellers drove price down but buyers recovered.
HammerIndicator hammer = new HammerIndicator(series);

// Custom thresholds
HammerIndicator hammerCustom = new HammerIndicator(series, 3.0, 0.5);

Rule entry = new BooleanIndicatorRule(hammer);
Constructor: InvertedHammerIndicator(BarSeries series)Single-candle bullish reversal in a downtrend: small body at the bottom, long upper shadow. Opposite shadow structure to a hammer; similar bullish implication after confirmation.
InvertedHammerIndicator invertedHammer = new InvertedHammerIndicator(series);
Constructor: BullishEngulfingIndicator(BarSeries series)Two-candle bullish reversal: a bearish candle followed by a bullish candle whose body completely engulfs the prior candle’s body (current open below prior open/close, current close above prior open/close).
BullishEngulfingIndicator bullEngulf = new BullishEngulfingIndicator(series);
Unstable bars: 1
Constructor: BullishHaramiIndicator(BarSeries series)Two-candle bullish reversal: a large bearish candle followed by a small bullish candle whose body is completely inside the prior body. Indicates indecision after a downtrend.
BullishHaramiIndicator bullHarami = new BullishHaramiIndicator(series);
Unstable bars: 1
Constructors:
  • MorningStarIndicator(BarSeries series) — defaults: small body 1.5%, big body 3%
  • MorningStarIndicator(BarSeries series, Num smallBodyThresholdPercentage, Num bigBodyThresholdPercentage)
Three-candle bullish reversal in a downtrend:
  1. Large bearish candle
  2. Small-bodied candle gapping down (the “star”)
  3. Large bullish candle closing above the midpoint of the first candle
MorningStarIndicator morningStar = new MorningStarIndicator(series);

// Custom thresholds
MorningStarIndicator morningStarCustom = new MorningStarIndicator(
    series,
    series.numFactory().numOf(0.01),  // small body threshold: 1%
    series.numFactory().numOf(0.025)  // big body threshold: 2.5%
);
Unstable bars: 2
Constructors:
  • PiercingIndicator(BarSeries series) — uses default body threshold
  • PiercingIndicator(BarSeries series, Num bigBodyThresholdPercentage)
Simpler piercing pattern check with a single body-size threshold.
PiercingIndicator piercing = new PiercingIndicator(series);
Constructors:
  • PiercingLineIndicator(BarSeries series) — defaults: big body 3%, gap 0%, penetration 50%
  • PiercingLineIndicator(BarSeries series, Num bigBodyThresholdPercentage, Num gapThresholdPercentage, Num penetrationThresholdPercentage)
Two-candle bullish reversal in a downtrend: a large bearish candle followed by a bullish candle that gaps down at the open and closes above the midpoint of the first candle. More configurable than PiercingIndicator.
PiercingLineIndicator piercing = new PiercingLineIndicator(series);
Constructors:
  • BullishMarubozuIndicator(BarSeries series) — 5-bar body average, body > average, shadows ≤ 5%
  • BullishMarubozuIndicator(BarSeries series, int bodyAveragePeriod, double bodyToAverageBodyRatio, double upperShadowToBodyRatio, double lowerShadowToBodyRatio)
Single-candle bullish pattern: a long bullish candle with both shadows very small relative to the body. Signals strong buying pressure with little hesitation.
BullishMarubozuIndicator bullMarubozu = new BullishMarubozuIndicator(series);

// Custom thresholds
BullishMarubozuIndicator bullMarubozuCustom = new BullishMarubozuIndicator(
    series, 5, 1.0, 0.05, 0.05
);
Constructor: BullishKickerIndicator(BarSeries series)Two-candle pattern: a bearish candle followed by a bullish candle that opens above the prior open (gap up). One of the most powerful reversal signals; rarely occurs.
BullishKickerIndicator bullKicker = new BullishKickerIndicator(series);
Constructor: ThreeWhiteSoldiersIndicator(BarSeries series, int barCount, Num factor)Four-candle pattern: one black (bearish) candle followed by three consecutive white (bullish) soldiers, each opening within the prior body and closing above the prior close with a short upper shadow.
ThreeWhiteSoldiersIndicator soldiers = new ThreeWhiteSoldiersIndicator(
    series,
    3,
    series.numFactory().numOf(0.1)
);
Unstable bars: 4
Constructor: ThreeInsideUpIndicator(BarSeries series)Confirms a Bullish Harami with a third candle closing above the first candle’s close.
ThreeInsideUpIndicator threeUp = new ThreeInsideUpIndicator(series);

Bearish patterns

Constructors:
  • ShootingStarIndicator(BarSeries series) — default ratios: body-to-upper-wick ≥ 2, body-to-lower-wick ≤ 1
  • ShootingStarIndicator(BarSeries series, double bodyToBottomWickRatio, double bodyToUpperWickRatio)
Single-candle bearish reversal in an uptrend: small body at the bottom, long upper shadow at least twice the body, tiny or absent lower shadow. Mirror of the Hammer pattern.
ShootingStarIndicator shootingStar = new ShootingStarIndicator(series);
Rule exit = new BooleanIndicatorRule(shootingStar);
Constructor: HangingManIndicator(BarSeries series)Same shape as a hammer (long lower shadow) but occurs in an uptrend, signaling a potential bearish reversal.
HangingManIndicator hangingMan = new HangingManIndicator(series);
Constructors:
  • EveningStarIndicator(BarSeries series) — defaults: small body 1.5%, big body 3%
  • EveningStarIndicator(BarSeries series, Num smallBodyThresholdPercentage, Num bigBodyThresholdPercentage)
Three-candle bearish reversal in an uptrend:
  1. Large bullish candle
  2. Small-bodied candle gapping up (the “star”)
  3. Large bearish candle closing below the midpoint of the first candle
Bearish mirror of Morning Star.
EveningStarIndicator eveningStar = new EveningStarIndicator(series);
Unstable bars: 2
Constructors:
  • DarkCloudIndicator(BarSeries series) — uses default body threshold
  • DarkCloudIndicator(BarSeries series, Num bigBodyThresholdPercentage)
Simpler dark cloud check with a single body-size threshold. Use DarkCloudCoverIndicator for full configurable gap/penetration thresholds.
DarkCloudIndicator darkCloud = new DarkCloudIndicator(series);
Constructors:
  • DarkCloudCoverIndicator(BarSeries series) — defaults: big body 3%, gap 0%, penetration 50%
  • DarkCloudCoverIndicator(BarSeries series, Num bigBodyThresholdPercentage, Num gapThresholdPercentage, Num penetrationThresholdPercentage)
Two-candle bearish reversal in an uptrend: a large bullish candle followed by a bearish candle that gaps up at the open and closes below the midpoint of the first candle. Bearish mirror of Piercing Line.
DarkCloudCoverIndicator darkCloud = new DarkCloudCoverIndicator(series);
Constructor: BearishEngulfingIndicator(BarSeries series)Two-candle bearish reversal: a bullish candle followed by a bearish candle whose body completely engulfs the prior body.
BearishEngulfingIndicator bearEngulf = new BearishEngulfingIndicator(series);
Unstable bars: 1
Constructor: BearishHaramiIndicator(BarSeries series)Two-candle bearish reversal: a large bullish candle followed by a small bearish candle contained entirely within the prior body.
BearishHaramiIndicator bearHarami = new BearishHaramiIndicator(series);
Unstable bars: 1
Constructors:
  • BearishMarubozuIndicator(BarSeries series)
  • BearishMarubozuIndicator(BarSeries series, int bodyAveragePeriod, double bodyToAverageBodyRatio, double upperShadowToBodyRatio, double lowerShadowToBodyRatio)
Single-candle bearish pattern: long bearish candle with tiny shadows, signaling strong selling pressure.
BearishMarubozuIndicator bearMarubozu = new BearishMarubozuIndicator(series);
Constructor: BearishKickerIndicator(BarSeries series)A bullish candle followed by a bearish candle that opens below the prior open (gap down). Strong bearish reversal signal.
BearishKickerIndicator bearKicker = new BearishKickerIndicator(series);
Constructor: ThreeBlackCrowsIndicator(BarSeries series, int barCount, Num factor)Three consecutive large bearish candles, each opening within the prior body and closing lower. Bearish mirror of Three White Soldiers.
ThreeBlackCrowsIndicator crows = new ThreeBlackCrowsIndicator(
    series,
    3,
    series.numFactory().numOf(0.1)
);
Constructor: ThreeInsideDownIndicator(BarSeries series)Confirms a Bearish Harami with a third candle closing below the first candle’s close.
ThreeInsideDownIndicator threeDown = new ThreeInsideDownIndicator(series);

Doji

Constructor: DojiIndicator(BarSeries series, int barCount, double bodyFactor)A candle is Doji when its body height is less than bodyFactor × average(body height over barCount). Doji represents indecision between buyers and sellers; context determines whether it is bullish or bearish.
// Body must be less than 10% of the 14-bar average body height
DojiIndicator doji = new DojiIndicator(series, 14, 0.1);

// Doji after a long uptrend = potential reversal warning
Rule dojiAlert = new BooleanIndicatorRule(doji);

Using patterns in strategies

BarSeries series = ...;

// Detect a Morning Star followed by RSI confirmation
MorningStarIndicator morningStar = new MorningStarIndicator(series);
RSIIndicator rsi = new RSIIndicator(new ClosePriceIndicator(series), 14);

Strategy strategy = new BaseStrategy(
    new BooleanIndicatorRule(morningStar)
        .and(new UnderIndicatorRule(rsi, 40)),   // entry: morning star + RSI not overbought
    new BooleanIndicatorRule(new ShootingStarIndicator(series))
        .or(new OverIndicatorRule(rsi, 70))       // exit: shooting star or RSI overbought
);
Pattern indicators check the trend direction (uptrend/downtrend) internally using UpTrendIndicator and DownTrendIndicator. The warm-up period of those internal indicators contributes to the pattern indicator’s getCountOfUnstableBars().