Class GainRTIndicator

All Implemented Interfaces:
ClockAware, PeriodCounter, Resettable, RTIndicator

public class GainRTIndicator extends PeriodCounterRTIndicator
Tracks positive price changes (gains) between consecutive updates. Returns the gain amount (newValue - prevValue) when the price increases, and 0 otherwise. Maintains a period counter tracking consecutive gain periods. The counter can optionally reset when the price stays flat (configurable via resetPeriodsOnSustain).
  • Constructor Details

    • GainRTIndicator

      public GainRTIndicator()
    • GainRTIndicator

      public GainRTIndicator(RTIndicator indicator)
  • Method Details

    • resetPeriodsOnSustain

      public GainRTIndicator resetPeriodsOnSustain(boolean resetPeriodsOnSustain)
    • initValue

      protected double initValue(double initValue)
      Description copied from class: AbstractIncrementalRTIndicator
      Non periodic init value
      Overrides:
      initValue in class AbstractIncrementalRTIndicator
      Parameters:
      initValue -
      Returns:
    • getPrevValue

      protected double getPrevValue()
      Overrides:
      getPrevValue in class AbstractIncrementalRTIndicator
    • nextValue

      protected double nextValue(double prevValue, double newValue)
      Computes the gain between consecutive values. Returns the positive difference when the price increases (and increments the period counter), or 0 when flat or declining. Period counter resets on decline, and optionally on sustained (flat) values.
      Overrides:
      nextValue in class PeriodCounterRTIndicator
      Parameters:
      prevValue - the previous raw input value
      newValue - the current raw input value
      Returns:
      the gain amount, or 0 if no gain
    • isResetPeriodsOnSustain

      public boolean isResetPeriodsOnSustain()