Class BollingerBandsRTIndicator

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

public class BollingerBandsRTIndicator extends AbstractRTIndicator
Bollinger bands RTIndicator
See Also:
  • 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

    • BollingerBandsRTIndicator

      public BollingerBandsRTIndicator()
    • BollingerBandsRTIndicator

      public BollingerBandsRTIndicator(int periods, Number k)
    • BollingerBandsRTIndicator

      public BollingerBandsRTIndicator(RTIndicator indicator, int periods, Number k)
  • Method Details

    • isReady

      public boolean isReady()
      Description copied from interface: RTIndicator
      Returns whether this indicator has received enough data to produce meaningful values.

      During the warmup period, RTIndicator.getValue() may return 0 or a partial estimate that should not be used for trading decisions. Once this method returns true, the indicator's output is statistically valid.

      The default implementation returns true for backward compatibility. Indicators with warmup requirements should override this method.

      For composite indicators (e.g. Bollinger Bands, MACD), readiness is determined by the slowest internal component.

      An indicator derived from other indicators (a distance between two of them, a function of one, a view of a parent's band) is ready when all the indicators it reads are ready, plus its own warm-up if it has one. It must not report ready from the first point while its sources are still warming up, and resetting it returns the indicators it updates to their start.

      Returns:
      true if the indicator has completed its warmup period
    • reset

      public void reset()
      Specified by:
      reset in interface Resettable
      Overrides:
      reset in class AbstractRTIndicator
    • withAverageSample

      public BollingerBandsRTIndicator withAverageSample(boolean averageSample)
    • withPrecision

      public BollingerBandsRTIndicator withPrecision(VariancePrecision precision)
      Chooses how the variance behind the bands is worked out: VariancePrecision.EXACT (the default; the bands keep their width in quiet markets, O(periods) per tick) or the O(1) VariancePrecision.FAST, which keeps the rounding of the variance below about one part in a thousand million. Reconfigure before feeding the indicator.
    • getPrecision

      public VariancePrecision getPrecision()
    • getStdDev

      public RTIndicator getStdDev()
    • getUpper

      public RTIndicator getUpper()
    • getLower

      public RTIndicator getLower()
    • getBandWidth

      public BollingerBandWidthRTIndicator getBandWidth()
    • update

      public double update(double newValue)
      Computes the Bollinger Bands for a new value. The middle band is the SMA (retrieved from the variance's internal SMA). Upper and lower bands are computed as middle +/- (k * standard deviation). All three bands are updated atomically on each call.
      Specified by:
      update in interface RTIndicator
      Overrides:
      update in class AbstractRTIndicator
      Parameters:
      newValue - the new input price
      Returns:
      the middle band value (SMA)