Class DistanceRTIndicator

java.lang.Object
com.wualabs.qtsurfer.engine.indicators.core.AbstractRTIndicator
com.wualabs.qtsurfer.engine.indicators.distance.DistanceRTIndicator
All Implemented Interfaces:
Resettable, RTIndicator

public class DistanceRTIndicator extends AbstractRTIndicator
Distance from 2 indicators
  • Field Details

    • ID

      public static final String ID
      Canonical catalog id, set as an explicit IndicatorMeta.ID override where getId() class-name derivation would be wrong.
      See Also:
  • Constructor Details

    • DistanceRTIndicator

      public DistanceRTIndicator(@NonNull @NonNull RTIndicator indicator, @NonNull @NonNull RTIndicator baseIndicator)
  • Method Details

    • isReady

      public boolean isReady()
      Ready when both of the indicators it measures are: a distance needs the two of them.
      Returns:
      true if the indicator has completed its warmup period
    • reset

      public void reset()
      Returns both indicators it updates to their pre-first-update state, as a holder does.
      Specified by:
      reset in interface Resettable
      Overrides:
      reset in class AbstractRTIndicator
    • update

      public double update(double newValue)
      Computes the fractional distance between two indicators: (indicator - base) / base. Both indicators receive the same input value. Returns 0 when the base is zero to avoid division by zero.
      Specified by:
      update in interface RTIndicator
      Overrides:
      update in class AbstractRTIndicator
      Parameters:
      newValue - the input value forwarded to both indicators
      Returns:
      the fractional distance between the two indicator values