Class BollingerBandsRTIndicator
- All Implemented Interfaces:
Resettable, RTIndicator
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBollingerBandsRTIndicator(int periods, Number k) BollingerBandsRTIndicator(RTIndicator indicator, int periods, Number k) -
Method Summary
Modifier and TypeMethodDescriptiongetLower()getUpper()booleanisReady()Returns whether this indicator has received enough data to produce meaningful values.voidreset()doubleupdate(double newValue) Computes the Bollinger Bands for a new value.withAverageSample(boolean averageSample) 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.Methods inherited from class AbstractRTIndicator
equals, getDisplayHint, getMeta, getValue, hashCode, hide, isPoison, setValue, toString, toString, withDisplayHint, withMeta
-
Field Details
-
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
-
BollingerBandsRTIndicator
-
-
Method Details
-
isReady
public boolean isReady()Description copied from interface:RTIndicatorReturns 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 returnstrue, the indicator's output is statistically valid.The default implementation returns
truefor 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:
trueif the indicator has completed its warmup period
-
reset
public void reset()- Specified by:
resetin interfaceResettable- Overrides:
resetin classAbstractRTIndicator
-
withAverageSample
-
withPrecision
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
-
getStdDev
-
getUpper
-
getLower
-
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:
updatein interfaceRTIndicator- Overrides:
updatein classAbstractRTIndicator- Parameters:
newValue- the new input price- Returns:
- the middle band value (SMA)
-