Class RTIndicatorAdapter
- All Implemented Interfaces:
Resettable, RTIndicator
Always feeds the underlying BarSeries on each update(double) call using
synthetic incremental timestamps to avoid syscalls and timestamp collisions.
-
Method Summary
Modifier and TypeMethodDescriptiondoublegetValue()booleanisReady()Returns whether this indicator has received enough data to produce meaningful values.static RTIndicatorof(Function<org.ta4j.core.BarSeries, org.ta4j.core.Indicator<org.ta4j.core.num.Num>> indicatorFactory, int maxBarCount) Creates an adapter with a factory function, supportingreset().static RTIndicatorof(org.ta4j.core.Indicator<org.ta4j.core.num.Num> indicator) Convenience method for an already-constructed indicator.voidreset()Resets the adapter by rebuilding the bar series and re-applying the indicator factory.doubleupdate(double newValue) Appends a new bar to the underlying series and recalculates the indicator.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface RTIndicator
getDisplayHint, getId, getMeta, isHidden, ro, update, update
-
Method Details
-
of
public static RTIndicator of(Function<org.ta4j.core.BarSeries, org.ta4j.core.Indicator<org.ta4j.core.num.Num>> indicatorFactory, int maxBarCount) Creates an adapter with a factory function, supportingreset().- Parameters:
indicatorFactory- builds the ta4j indicator from a fresh seriesmaxBarCount- maximum number of bars the series will retain- Returns:
- a new RTIndicator backed by ta4j
-
of
Convenience method for an already-constructed indicator. The adapter takes ownership of the indicator's series.reset()is a no-op since there is no factory to recreate the indicator.- Parameters:
indicator- a pre-built ta4j indicator- Returns:
- a new RTIndicator backed by ta4j
-
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.
- Specified by:
isReadyin interfaceRTIndicator- Returns:
trueif the indicator has completed its warmup period
-
getValue
public double getValue()- Specified by:
getValuein interfaceRTIndicator
-
update
public double update(double newValue) Appends a new bar to the underlying series and recalculates the indicator.Each call increments a monotonic tick counter to produce a synthetic timestamp (base + tickCount ms), avoiding system clock calls and guaranteeing uniqueness. Only the close price is populated; open/high/low are set to zero.
- Specified by:
updatein interfaceRTIndicator- Parameters:
newValue- the close price for the new bar- Returns:
- the updated indicator value after appending the bar
-
reset
public void reset()Resets the adapter by rebuilding the bar series and re-applying the indicator factory.The tick counter is zeroed so synthetic timestamps restart from the base epoch. If this adapter was created via
of(Indicator), the factory simply returns the original indicator instance, making the reset a partial no-op on the indicator side.- Specified by:
resetin interfaceResettable
-