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.

Trend indicators answer two questions: which direction is price moving, and how strong is that move? They range from simple moving averages to multi-component systems like Ichimoku and ADX.

Moving averages

Constructor: SMAIndicator(Indicator<Num> indicator, int barCount)Calculates the arithmetic mean of the last barCount values. The simplest and most widely used average; every bar has equal weight.
ClosePriceIndicator close = new ClosePriceIndicator(series);
SMAIndicator sma20 = new SMAIndicator(close, 20);
SMAIndicator sma50 = new SMAIndicator(close, 50);

Num value = sma20.getValue(series.getEndIndex());
Unstable bars: input.getCountOfUnstableBars() + barCount - 1
Constructor: EMAIndicator(Indicator<Num> indicator, int barCount)Applies exponentially decreasing weights with smoothing factor 2 / (barCount + 1). Reacts faster than SMA to recent price changes. Resets gracefully on NaN input.
ClosePriceIndicator close = new ClosePriceIndicator(series);
EMAIndicator ema12 = new EMAIndicator(close, 12);
EMAIndicator ema26 = new EMAIndicator(close, 26);

// Use as MACD inputs or standalone trend filter
Num fastEma = ema12.getValue(series.getEndIndex());
Unstable bars: barCount
Constructor: WMAIndicator(Indicator<Num> indicator, int barCount)Assigns linearly increasing weights so the most recent bar has the highest weight. More responsive than SMA but smoother than EMA.
ClosePriceIndicator close = new ClosePriceIndicator(series);
WMAIndicator wma = new WMAIndicator(close, 14);
Unstable bars: input.getCountOfUnstableBars() + barCount - 1
Constructor: HMAIndicator(Indicator<Num> indicator, int barCount)Combines two WMAs to dramatically reduce lag while maintaining smoothness: WMA(2 * WMA(n/2) - WMA(n), sqrt(n)). Well suited for fast-moving markets.
ClosePriceIndicator close = new ClosePriceIndicator(series);
HMAIndicator hma = new HMAIndicator(close, 16);
Constructor: DMAIndicator(Indicator<Num> indicator, int barCount, int displacement)An SMA shifted forward (displacement > 0) or backward (displacement < 0) in time. Positive displacement projects the average ahead to anticipate support/resistance.
ClosePriceIndicator close = new ClosePriceIndicator(series);
// SMA(20) displaced 5 bars forward
DMAIndicator dma = new DMAIndicator(close, 20, 5);
Constructors:
  • KAMAIndicator(Indicator<Num> price) — defaults: efficiency ratio period 10, fast 2, slow 30
  • KAMAIndicator(Indicator<Num> price, int barCountEffectiveRatio, int barCountFast, int barCountSlow)
Adapts its smoothing constant based on market noise via an Efficiency Ratio. Speeds up in trending markets and slows during consolidation.
ClosePriceIndicator close = new ClosePriceIndicator(series);
// Default parameters (10, 2, 30)
KAMAIndicator kama = new KAMAIndicator(close);

// Custom parameters
KAMAIndicator kamaCustom = new KAMAIndicator(close, 10, 2, 30);
Unstable bars: price.getCountOfUnstableBars() + barCountEffectiveRatio
Constructor: DoubleEMAIndicator(Indicator<Num> indicator, int barCount)Reduces EMA lag by applying EMA twice: 2 * EMA(n) - EMA(EMA(n)).
DoubleEMAIndicator dema = new DoubleEMAIndicator(new ClosePriceIndicator(series), 20);
Constructor: TripleEMAIndicator(Indicator<Num> indicator, int barCount)Further reduces lag: 3 * EMA - 3 * EMA(EMA) + EMA(EMA(EMA)).
TripleEMAIndicator tema = new TripleEMAIndicator(new ClosePriceIndicator(series), 20);
Constructor: MMAIndicator(Indicator<Num> indicator, int barCount)Wilder’s smoothed moving average with multiplier 1 / barCount. Used internally by RSI, ATR, and ADX.
MMAIndicator wilders = new MMAIndicator(new ClosePriceIndicator(series), 14);
ClassDescription
ATMAIndicator(indicator, barCount)Adaptive Triangular MA
EDMAIndicator(indicator, barCount)Exponentially Displaced MA
JMAIndicator(indicator, barCount, phase, power)Jurik MA
KiJunV2Indicator(indicator, barCount)Kijun-based MA variant
LSMAIndicator(indicator, barCount)Least Squares MA
LWMAIndicator(indicator, barCount)Linear Weighted MA
MCGinleyMAIndicator(indicator, barCount)McGinley Dynamic
SGMAIndicator(indicator, barCount)Savitzky-Golay MA
SMMAIndicator(indicator, barCount)Smoothed MA
TMAIndicator(indicator, barCount)Triangular MA
VIDYAIndicator(indicator, barCount)Variable Index Dynamic Average
VWMAIndicator(indicator, barCount)Volume-Weighted MA
WildersMAIndicator(indicator, barCount)Wilder’s MA alias
ZLEMAIndicator(indicator, barCount)Zero-Lag EMA

MACD

Constructors:
  • MACDIndicator(Indicator<Num> indicator) — defaults: short 12, long 26
  • MACDIndicator(Indicator<Num> indicator, int shortBarCount, int longBarCount)
MACD = EMA(short) - EMA(long). Exposes the signal line and histogram via helper methods.
ClosePriceIndicator close = new ClosePriceIndicator(series);

MACDIndicator macd         = new MACDIndicator(close, 12, 26);
EMAIndicator  signal       = macd.getSignalLine(9);
NumericIndicator histogram = macd.getHistogram(9);

int idx = series.getEndIndex();
System.out.println("MACD:      " + macd.getValue(idx));
System.out.println("Signal:    " + signal.getValue(idx));
System.out.println("Histogram: " + histogram.getValue(idx));
Constructor: MACDVIndicator(BarSeries series, int shortBarCount, int longBarCount)Volume-weighted MACD variant.
MACDVIndicator macdv = new MACDVIndicator(series, 12, 26);

ADX — Average Directional Index

Constructors:
  • ADXIndicator(BarSeries series, int barCount) — same period for DI and ADX smoothing
  • ADXIndicator(BarSeries series, int diBarCount, int adxBarCount)
ADX measures trend strength (0–100) regardless of direction. Values above 25 indicate a strong trend.
ADXIndicator  adx     = new ADXIndicator(series, 14);
PlusDIIndicator  plusDI  = new PlusDIIndicator(series, 14);
MinusDIIndicator minusDI = new MinusDIIndicator(series, 14);

int idx = series.getEndIndex();
Num adxVal    = adx.getValue(idx);      // trend strength
Num plusDIVal = plusDI.getValue(idx);   // +DI: upward pressure
Num minDIVal  = minusDI.getValue(idx);  // -DI: downward pressure
Constructors:
  • PlusDIIndicator(BarSeries series, int barCount) — +DI (upward directional movement)
  • MinusDIIndicator(BarSeries series, int barCount) — -DI (downward directional movement)
DI crossovers signal trend changes: when +DI crosses above -DI, a new uptrend may be starting.
PlusDIIndicator  plusDI  = new PlusDIIndicator(series, 14);
MinusDIIndicator minusDI = new MinusDIIndicator(series, 14);

Rule entryRule = new CrossedUpIndicatorRule(plusDI, minusDI);

Aroon

Constructors:
  • AroonUpIndicator(BarSeries series, int barCount) — time since highest high, scaled 0–100
  • AroonUpIndicator(Indicator<Num> highPriceIndicator, int barCount) — custom high source
  • AroonDownIndicator(BarSeries series, int barCount) — time since lowest low, scaled 0–100
AroonUpIndicator   aroonUp   = new AroonUpIndicator(series, 25);
AroonDownIndicator aroonDown = new AroonDownIndicator(series, 25);

// Aroon Up > 70 and Aroon Down < 30 = strong uptrend
Constructor: AroonOscillatorIndicator(BarSeries series, int barCount)AroonUp - AroonDown. Oscillates between -100 and +100. Positive values favor uptrend; negative favor downtrend.
AroonOscillatorIndicator aroonOsc = new AroonOscillatorIndicator(series, 25);
Num osc = aroonOsc.getValue(series.getEndIndex());

Ichimoku Cloud

All Ichimoku components accept a BarSeries and use standard defaults when called with no period arguments.
Constructors:
  • IchimokuTenkanSenIndicator(BarSeries series) — default period 9
  • IchimokuTenkanSenIndicator(BarSeries series, int barCount)
(highest high + lowest low) / 2 over barCount bars.
IchimokuTenkanSenIndicator tenkan = new IchimokuTenkanSenIndicator(series, 9);
Constructors:
  • IchimokuKijunSenIndicator(BarSeries series) — default period 26
  • IchimokuKijunSenIndicator(BarSeries series, int barCount)
Same formula as Tenkan-sen but over a longer period (typically 26 bars). Acts as dynamic support/resistance.
IchimokuKijunSenIndicator kijun = new IchimokuKijunSenIndicator(series, 26);
Constructors:
  • IchimokuSenkouSpanAIndicator(BarSeries series) — tenkan 9, kijun 26, offset 26
  • IchimokuSenkouSpanAIndicator(BarSeries series, int barCountConversionLine, int barCountBaseLine)
  • IchimokuSenkouSpanAIndicator(BarSeries series, IchimokuTenkanSenIndicator conversionLine, IchimokuKijunSenIndicator baseLine, int offset)
(Tenkan-sen + Kijun-sen) / 2 plotted offset bars ahead. Forms the top or bottom of the Kumo cloud.
IchimokuSenkouSpanAIndicator spanA = new IchimokuSenkouSpanAIndicator(series);
Constructors:
  • IchimokuSenkouSpanBIndicator(BarSeries series) — period 52, offset 26
  • IchimokuSenkouSpanBIndicator(BarSeries series, int barCount)
  • IchimokuSenkouSpanBIndicator(BarSeries series, int barCount, int offset)
(highest high + lowest low) / 2 over 52 bars, plotted 26 bars ahead. Forms the opposite boundary of the cloud.
IchimokuSenkouSpanBIndicator spanB = new IchimokuSenkouSpanBIndicator(series, 52, 26);
Constructors:
  • IchimokuChikouSpanIndicator(BarSeries series) — default delay 26
  • IchimokuChikouSpanIndicator(BarSeries series, int timeDelay)
Close price plotted timeDelay bars behind current price. Used to confirm trend direction by comparing the lagging span to past price.
IchimokuChikouSpanIndicator chikou = new IchimokuChikouSpanIndicator(series, 26);
BarSeries series = ...;

IchimokuTenkanSenIndicator   tenkan = new IchimokuTenkanSenIndicator(series, 9);
IchimokuKijunSenIndicator    kijun  = new IchimokuKijunSenIndicator(series, 26);
IchimokuSenkouSpanAIndicator spanA  = new IchimokuSenkouSpanAIndicator(series);
IchimokuSenkouSpanBIndicator spanB  = new IchimokuSenkouSpanBIndicator(series);
IchimokuChikouSpanIndicator  chikou = new IchimokuChikouSpanIndicator(series);

int idx = series.getEndIndex();
Num close = series.getBar(idx).getClosePrice();

// Price above cloud = uptrend confirmation
boolean aboveCloud = close.isGreaterThan(spanA.getValue(idx))
                  && close.isGreaterThan(spanB.getValue(idx));

Parabolic SAR

Constructors:
  • ParabolicSarIndicator(BarSeries series) — defaults: aF 0.02, maxA 0.2, increment 0.02
  • ParabolicSarIndicator(BarSeries series, Num aF, Num maxA)
  • ParabolicSarIndicator(BarSeries series, Num aF, Num maxA, Num increment)
A stop-and-reverse system that places dots above price (downtrend) or below price (uptrend). Useful for trailing stop placement.
ParabolicSarIndicator sar = new ParabolicSarIndicator(series);

// Custom parameters
NumFactory nf = series.numFactory();
ParabolicSarIndicator sarCustom = new ParabolicSarIndicator(
    series,
    nf.numOf(0.02),   // acceleration factor start
    nf.numOf(0.2),    // maximum acceleration
    nf.numOf(0.02)    // increment step
);

Num sarValue = sar.getValue(series.getEndIndex());
Num close    = series.getBar(series.getEndIndex()).getClosePrice();
boolean bullish = close.isGreaterThan(sarValue);

SuperTrend

Constructors:
  • SuperTrendIndicator(BarSeries series) — defaults: ATR period 10, multiplier 3.0
  • SuperTrendIndicator(BarSeries series, int barCount, double multiplier)
A dynamic support/resistance line based on ATR bands. The indicator flips between the upper and lower band as price breaks through. Exposes isUpTrend(int index), isDownTrend(int index), and trendChanged(int index).
SuperTrendIndicator st = new SuperTrendIndicator(series, 10, 3.0);

int idx = series.getEndIndex();
if (st.trendChanged(idx) && st.isUpTrend(idx)) {
    System.out.println("Buy signal at bar " + idx);
}
Access the individual bands directly when you need raw band values:
ATRIndicator atr = new ATRIndicator(series, 10);
SuperTrendUpperBandIndicator upper = new SuperTrendUpperBandIndicator(series, atr, 3.0);
SuperTrendLowerBandIndicator lower = new SuperTrendLowerBandIndicator(series, atr, 3.0);
These are also accessible from SuperTrendIndicator:
SuperTrendIndicator st = new SuperTrendIndicator(series);
SuperTrendUpperBandIndicator upper = st.getSuperTrendUpperBandIndicator();
SuperTrendLowerBandIndicator lower = st.getSuperTrendLowerBandIndicator();

Other trend indicators

Constructor: RAVIIndicator(Indicator<Num> indicator, int shortBarCount, int longBarCount)Measures the percentage difference between a short and long SMA. Filters choppy markets: high RAVI = strong trend.
ClosePriceIndicator close = new ClosePriceIndicator(series);
RAVIIndicator ravi = new RAVIIndicator(close, 7, 65);
Constructor: DistanceFromMAIndicator(Indicator<Num> indicator, Indicator<Num> maIndicator)Percentage distance of price from a moving average. Useful for mean-reversion strategies.
ClosePriceIndicator close = new ClosePriceIndicator(series);
SMAIndicator sma = new SMAIndicator(close, 20);
DistanceFromMAIndicator dist = new DistanceFromMAIndicator(close, sma);
Constructor: AlligatorIndicator(BarSeries series)Bill Williams’ Alligator: three smoothed moving averages (Jaw, Teeth, Lips) with different periods and displacements.
AlligatorIndicator alligator = new AlligatorIndicator(series);