Class VolatilityRTIndicator

java.lang.Object
com.wualabs.qtsurfer.engine.indicators.core.AbstractRTIndicator
com.wualabs.qtsurfer.engine.indicators.helpers.VolatilityRTIndicator
All Implemented Interfaces:
Resettable, RTIndicator
Direct Known Subclasses:
PercentVolatilityRTIndicator

public class VolatilityRTIndicator extends AbstractRTIndicator
Measures price volatility by tracking whether consecutive values change. By default, feeds 1 (changed) or 0 (unchanged) into an averaging indicator and returns the result as a percentage. Supports an initial clamp period where getValue() returns 0 to suppress noisy startup values.
  • Constructor Details

    • VolatilityRTIndicator

      public VolatilityRTIndicator()
    • VolatilityRTIndicator

      public VolatilityRTIndicator(RTIndicator averageIndicator)
  • Method Details

    • clampUpdates

      public VolatilityRTIndicator clampUpdates(int clampUpdateCount)
    • update

      public double update(double newValue)
      Processes a new value by computing the volatility metric from the price change between consecutive updates. On the first call, only stores the initial value. During the clamp period, the stored value updates internally but getValue() returns 0 to suppress startup noise.
      Specified by:
      update in interface RTIndicator
      Overrides:
      update in class AbstractRTIndicator
      Parameters:
      newValue - the new input price
      Returns:
      the volatility value (or 0 during the clamp period)
    • getValue

      public double getValue()
      Returns the current volatility value, or 0 if still in the clamp period.
      Specified by:
      getValue in interface RTIndicator
      Overrides:
      getValue in class AbstractRTIndicator
    • nextValue

      protected double nextValue(RTIndicator averageIndicator, double prevValue, double newValue)
      Computes the volatility signal: feeds 1 (changed) or 0 (unchanged) into the averaging indicator and scales the result to a percentage.
      Parameters:
      averageIndicator - the averaging indicator for smoothing
      prevValue - the previous input value
      newValue - the current input value
      Returns:
      the averaged change rate as a percentage