Documentation, examples and further information of the ta4j project
This project is maintained by ta4j Organization
ta4j 0.22.3 adds a complete Bill Williams indicator stack so you can model trend context, breakout structure, and participation in one workflow.
In ta4j, the Bill Williams stack is implemented as composable indicators that plug directly into the standard Indicator + Rule + Strategy pipeline:
AlligatorIndicatorFractalHighIndicator / FractalLowIndicatorGatorOscillatorIndicator and MarketFacilitationIndexIndicatorThis matters in ta4j because each component can be backtested, combined with non-Bill-Williams indicators, and ranked with the same criteria stack used elsewhere in the library.
AlligatorIndicator – displaced SMMAs on median price (jaw, teeth, lips)FractalHighIndicator / FractalLowIndicator – confirmed fractal pivots (default 2/2 windows)GatorOscillatorIndicator – histogram spread between alligator linesMarketFacilitationIndexIndicator – Bill Williams MFI ((high - low) / volume)Use this suite when your ta4j strategy needs all three at once:
Typical ta4j use cases:
Avoid relying on it alone in very low-volume instruments or ultra-short bar horizons where (high - low) / volume becomes unstable/noisy.
Alligator canonical settings in ta4j follow Bill Williams defaults:
SMMA(13) shifted by 8SMMA(8) shifted by 5SMMA(5) shifted by 3Fractal defaults use 2 preceding + 2 following bars.
Fractal indicators confirm on the current bar. When a fractal is confirmed at index i, the pivot is earlier. Use getConfirmedFractalIndex(i) to retrieve the pivot index explicitly.
This avoids accidental look-ahead bias when building entry/exit rules.
In ta4j terms: FractalHighIndicator and FractalLowIndicator are Indicator<Boolean> implementations, so they are event/confirmation signals, not direct price levels.
BarSeries series = ...;
AlligatorIndicator jaw = AlligatorIndicator.jaw(series);
AlligatorIndicator teeth = AlligatorIndicator.teeth(series);
AlligatorIndicator lips = AlligatorIndicator.lips(series);
FractalHighIndicator fractalHigh = new FractalHighIndicator(series);
FractalLowIndicator fractalLow = new FractalLowIndicator(series);
GatorOscillatorIndicator gatorUpper = GatorOscillatorIndicator.upper(series);
GatorOscillatorIndicator gatorLower = GatorOscillatorIndicator.lower(series);
MarketFacilitationIndexIndicator bwMfi = new MarketFacilitationIndexIndicator(series);
Num zero = series.numFactory().zero();
Rule trendUp = new OverIndicatorRule(lips, teeth)
.and(new OverIndicatorRule(teeth, jaw));
Rule confirmedFractalBreakout = new BooleanIndicatorRule(fractalHigh);
Rule participation = new OverIndicatorRule(gatorUpper, zero)
.and(new OverIndicatorRule(bwMfi, zero));
Rule entryRule = trendUp.and(confirmedFractalBreakout).and(participation);
Why this pattern works in ta4j:
BooleanIndicatorRule consumes fractal confirmation events directly.OverIndicatorRule keeps numeric comparisons explicit and testable.Num values come from the series factory, keeping numeric type consistency.For realistic backtests, set unstable bars high enough to cover all dependency warm-up periods (Alligator displacement + fractal windows + any added filters).
Typical interpretation:
lips > teeth > jaw or inverse) for trend context.MarketFacilitationIndexIndicator is not the same indicator as MoneyFlowIndexIndicator.AlligatorIndicator displacement is implemented without look-ahead (value at i reads smoothed value at i - shift).GatorOscillatorIndicator.upper(...) and .lower(...) provide the two histogram branches separately.