Class RateChangeRTIndicator
java.lang.Object
com.wualabs.qtsurfer.engine.indicators.core.AbstractRTIndicator
com.wualabs.qtsurfer.engine.indicators.core.AbstractIncrementalRTIndicator
com.wualabs.qtsurfer.engine.indicators.core.AbstractDecorableIncrementalRTIndicator
com.wualabs.qtsurfer.engine.indicators.helpers.RateChangeRTIndicator
- All Implemented Interfaces:
ClockAware, Resettable, RTIndicator
Gets the rate of change of an RTIndicator between updates
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class AbstractDecorableIncrementalRTIndicator
getIndicator, reset, setClockSupplier, updateMethods inherited from class AbstractIncrementalRTIndicator
getLastUpdateValue, getPeriodCycles, getPeriods, isPeriodic, isReady, prevNextValue, setPeriods, tickValueMethods 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
-
RateChangeRTIndicator
-
-
Method Details
-
initValue
protected double initValue(double initValue) Description copied from class:AbstractIncrementalRTIndicatorNon periodic init value- Overrides:
initValuein classAbstractIncrementalRTIndicator- Parameters:
initValue-- Returns:
-
getPrevValue
protected double getPrevValue()- Overrides:
getPrevValuein classAbstractIncrementalRTIndicator
-
nextValue
protected double nextValue(double prevValue, double newValue) Computes the rate of change as (newValue - prevValue) / |prevValue|. Uses the absolute value of prevValue in the denominator to handle negative base values correctly. Returns 0 when prevValue is zero to avoid division by zero.- Overrides:
nextValuein classAbstractDecorableIncrementalRTIndicator- Parameters:
prevValue- the previous raw input valuenewValue- the current raw input value- Returns:
- the fractional rate of change
-