Class LossRTIndicator

All Implemented Interfaces:
ClockAware, PeriodCounter, Resettable, RTIndicator

public class LossRTIndicator extends PeriodCounterRTIndicator
Tracks negative price changes (losses) between consecutive updates. Returns the loss amount (prevValue - newValue) as a positive number when the price decreases, and 0 otherwise. Maintains a period counter tracking consecutive loss periods. The counter can optionally reset when the price stays flat.
  • Constructor Details

    • LossRTIndicator

      public LossRTIndicator()
    • LossRTIndicator

      public LossRTIndicator(RTIndicator indicator)
  • Method Details

    • resetPeriodsOnSustain

      public LossRTIndicator 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 loss between consecutive values. Returns the positive difference when the price decreases (and increments the period counter), or 0 when flat or rising. Period counter resets on gains, 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 loss amount (positive), or 0 if no loss
    • isResetPeriodsOnSustain

      public boolean isResetPeriodsOnSustain()