Class Indicators

java.lang.Object
com.quantfinlib.indicators.Indicators

public final class Indicators extends Object
Technical Indicator Engine: production-ready implementations of the standard technical analysis toolkit. All indicators operate on primitive arrays and return primitive arrays (or small records of arrays) aligned with the input: index i of the output corresponds to bar i, with NaN for warm-up bars.

Included: RSI, SMA, EMA, WMA, VWAP, MACD, ATR, ADX, CCI, ROC, Momentum, OBV, CMF, SuperTrend, Ichimoku Cloud, Stochastic RSI, Williams %R, Parabolic SAR, Bollinger Bands, Keltner Channel, Donchian Channel.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
     
    static final record 
     
    static final record 
     
    static final record 
     
    static final record 
     
    static final record 
     
    static final record 
     
    static final record 
    direction: +1 = uptrend (value is support), -1 = downtrend (value is resistance).
  • Method Summary

    Modifier and Type
    Method
    Description
    adx(BarSeries s, int period)
    Average Directional Index with +DI / -DI (Wilder).
    static double[]
    atr(BarSeries s, int period)
    Average True Range (Wilder smoothing).
    bollinger(double[] close, int period, double k)
    Bollinger Bands: SMA middle band with k population standard deviations.
    static double[]
    cci(BarSeries s, int period)
    Commodity Channel Index over typical price.
    static double[]
    cmf(BarSeries s, int period)
    Chaikin Money Flow.
    donchian(BarSeries s, int period)
    Donchian Channel: highest high / lowest low over the period.
    static double[]
    ema(double[] v, int period)
    Exponential moving average, seeded with the SMA of the first period values.
    static double[]
    highest(double[] v, int period)
     
    ichimoku(BarSeries s, int tenkanPeriod, int kijunPeriod, int senkouBPeriod)
    Ichimoku Cloud with standard forward/backward displacement: senkou spans are plotted kijunPeriod bars ahead, chikou kijunPeriod bars behind.
    keltner(BarSeries s, int emaPeriod, int atrPeriod, double multiplier)
    Keltner Channel: EMA middle band with ATR-based envelope.
    static double[]
    lowest(double[] v, int period)
     
    macd(double[] close, int fastPeriod, int slowPeriod, int signalPeriod)
    MACD: EMA(fast) - EMA(slow), with an EMA signal line and histogram.
    static double[]
    momentum(double[] v, int period)
    Momentum: v[i] - v[i-period].
    static double[]
    On-Balance Volume.
    static double[]
    parabolicSar(BarSeries s, double afStart, double afStep, double afMax)
    Parabolic SAR (standard Wilder acceleration schedule).
    static double[]
    roc(double[] v, int period)
    Rate of change, percent: (v[i] / v[i-period] - 1) * 100.
    static double[]
    rollingStd(double[] v, int period)
    Rolling population standard deviation.
    static double[]
    rsi(double[] v, int period)
    Relative Strength Index (Wilder smoothing).
    static double[]
    sma(double[] v, int period)
    Simple moving average.
    stochasticRsi(double[] close, int rsiPeriod, int stochPeriod, int kSmooth, int dSmooth)
    Stochastic RSI: stochastic oscillator applied to RSI, with %K and %D smoothing.
    superTrend(BarSeries s, int period, double multiplier)
    SuperTrend with ATR bands.
    static double[]
    True range series.
    static double[]
    Cumulative Volume-Weighted Average Price (anchored at the series start).
    static double[]
    williamsR(BarSeries s, int period)
    Williams %R: -100 * (highestHigh - close) / (highestHigh - lowestLow).
    static double[]
    wma(double[] v, int period)
    Linearly weighted moving average.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • sma

      public static double[] sma(double[] v, int period)
      Simple moving average.
    • ema

      public static double[] ema(double[] v, int period)
      Exponential moving average, seeded with the SMA of the first period values.
    • wma

      public static double[] wma(double[] v, int period)
      Linearly weighted moving average.
    • rsi

      public static double[] rsi(double[] v, int period)
      Relative Strength Index (Wilder smoothing).
    • roc

      public static double[] roc(double[] v, int period)
      Rate of change, percent: (v[i] / v[i-period] - 1) * 100.
    • momentum

      public static double[] momentum(double[] v, int period)
      Momentum: v[i] - v[i-period].
    • macd

      public static Indicators.Macd macd(double[] close, int fastPeriod, int slowPeriod, int signalPeriod)
      MACD: EMA(fast) - EMA(slow), with an EMA signal line and histogram.
    • stochasticRsi

      public static Indicators.StochRsi stochasticRsi(double[] close, int rsiPeriod, int stochPeriod, int kSmooth, int dSmooth)
      Stochastic RSI: stochastic oscillator applied to RSI, with %K and %D smoothing.
    • williamsR

      public static double[] williamsR(BarSeries s, int period)
      Williams %R: -100 * (highestHigh - close) / (highestHigh - lowestLow).
    • cci

      public static double[] cci(BarSeries s, int period)
      Commodity Channel Index over typical price.
    • trueRange

      public static double[] trueRange(BarSeries s)
      True range series.
    • atr

      public static double[] atr(BarSeries s, int period)
      Average True Range (Wilder smoothing).
    • adx

      public static Indicators.Adx adx(BarSeries s, int period)
      Average Directional Index with +DI / -DI (Wilder).
    • bollinger

      public static Indicators.Bollinger bollinger(double[] close, int period, double k)
      Bollinger Bands: SMA middle band with k population standard deviations.
    • keltner

      public static Indicators.Keltner keltner(BarSeries s, int emaPeriod, int atrPeriod, double multiplier)
      Keltner Channel: EMA middle band with ATR-based envelope.
    • donchian

      public static Indicators.Donchian donchian(BarSeries s, int period)
      Donchian Channel: highest high / lowest low over the period.
    • obv

      public static double[] obv(BarSeries s)
      On-Balance Volume.
    • vwap

      public static double[] vwap(BarSeries s)
      Cumulative Volume-Weighted Average Price (anchored at the series start).
    • cmf

      public static double[] cmf(BarSeries s, int period)
      Chaikin Money Flow.
    • superTrend

      public static Indicators.SuperTrend superTrend(BarSeries s, int period, double multiplier)
      SuperTrend with ATR bands.
    • ichimoku

      public static Indicators.Ichimoku ichimoku(BarSeries s, int tenkanPeriod, int kijunPeriod, int senkouBPeriod)
      Ichimoku Cloud with standard forward/backward displacement: senkou spans are plotted kijunPeriod bars ahead, chikou kijunPeriod bars behind.
    • parabolicSar

      public static double[] parabolicSar(BarSeries s, double afStart, double afStep, double afMax)
      Parabolic SAR (standard Wilder acceleration schedule).
    • highest

      public static double[] highest(double[] v, int period)
    • lowest

      public static double[] lowest(double[] v, int period)
    • rollingStd

      public static double[] rollingStd(double[] v, int period)
      Rolling population standard deviation.