Class PercentChangePeriodRTIndicator
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.PercentChangePeriodRTIndicator
- All Implemented Interfaces:
ClockAware, Resettable, RTIndicator
Calculates the percent change over periods tracked by a
PeriodCounter indicator.-
Constructor Summary
ConstructorsModifierConstructorDescriptionPercentChangePeriodRTIndicator(PeriodCounterRTIndicator periodCounterRTIndicator) <T extends RTIndicator & PeriodCounter>PercentChangePeriodRTIndicator(T indicator) -
Method Summary
Modifier and TypeMethodDescriptiondoubledoublelongdoubleupdate(double newValue) Computes the percent change relative to the initial value at the start of the current period sequence.Methods inherited from class AbstractDecorableIncrementalRTIndicator
getIndicator, nextValue, reset, setClockSupplierMethods inherited from class AbstractIncrementalRTIndicator
getLastUpdateValue, getPeriodCycles, getPeriods, getPrevValue, initValue, isPeriodic, isReady, prevNextValue, setPeriods, tickValueMethods inherited from class AbstractRTIndicator
equals, getDisplayHint, getMeta, getValue, hashCode, hide, isPoison, setValue, toString, toString, withDisplayHint, withMeta
-
Constructor Details
-
PercentChangePeriodRTIndicator
-
PercentChangePeriodRTIndicator
-
-
Method Details
-
getPeriodCount
public long getPeriodCount() -
getInitialValue
public double getInitialValue() -
getPercentChange
public double getPercentChange() -
update
public double update(double newValue) Computes the percent change relative to the initial value at the start of the current period sequence. When the period counter resets to zero, captures a new initial value and returns 0. Uses a default baseline of 100 when the initial value is zero to avoid division by zero. The stored value is the fractional change (multiply by 100 for percentage).- Specified by:
updatein interfaceRTIndicator- Overrides:
updatein classAbstractDecorableIncrementalRTIndicator- Parameters:
newValue- the new input value- Returns:
- the fractional change relative to the period's initial value
-