Class MacdRTIndicator

All Implemented Interfaces:
ClockAware, Resettable, RTIndicator

public class MacdRTIndicator extends AbstractDecorableIncrementalRTIndicator
MACD RTIndicator
  • Constructor Details

    • MacdRTIndicator

      public MacdRTIndicator()
    • MacdRTIndicator

      public MacdRTIndicator(RTIndicator indicator)
    • MacdRTIndicator

      public MacdRTIndicator(RTIndicator indicator, int shortEmaPeriods, int longEmaPeriods)
  • Method Details

    • isReady

      public boolean isReady()
      Ready when both EMAs are, which is when the slower of the two is. MACD is the difference of two averages, so it says nothing while either is still warming up.
      Specified by:
      isReady in interface RTIndicator
      Overrides:
      isReady in class AbstractDecorableIncrementalRTIndicator
      Returns:
      true if the indicator has completed its warmup period
    • reset

      public void reset()
      Specified by:
      reset in interface Resettable
      Overrides:
      reset in class AbstractDecorableIncrementalRTIndicator
    • update

      public double update(double newValue)
      Computes the MACD line as the difference between the short-period EMA and the long-period EMA. Both EMAs are updated with the same input value, and the difference is passed to the parent incremental pipeline.
      Specified by:
      update in interface RTIndicator
      Overrides:
      update in class AbstractDecorableIncrementalRTIndicator
      Parameters:
      newValue - the new input price
      Returns:
      the MACD line value (shortEMA - longEMA)