Class GainRTIndicator
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.PeriodCounterRTIndicator
com.wualabs.qtsurfer.engine.indicators.helpers.GainRTIndicator
- All Implemented Interfaces:
ClockAware, PeriodCounter, Resettable, RTIndicator
Tracks positive price changes (gains) between consecutive updates.
Returns the gain amount (newValue - prevValue) when the price increases,
and 0 otherwise. Maintains a period counter tracking consecutive gain periods.
The counter can optionally reset when the price stays flat (configurable via
resetPeriodsOnSustain).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected doubleprotected doubleinitValue(double initValue) Non periodic init valuebooleanprotected doublenextValue(double prevValue, double newValue) Computes the gain between consecutive values.resetPeriodsOnSustain(boolean resetPeriodsOnSustain) Methods inherited from class PeriodCounterRTIndicator
getPeriodCount, incPeriods, resetPeriodsMethods 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
-
Constructor Details
-
GainRTIndicator
public GainRTIndicator() -
GainRTIndicator
-
-
Method Details
-
resetPeriodsOnSustain
-
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 gain between consecutive values. Returns the positive difference when the price increases (and increments the period counter), or 0 when flat or declining. Period counter resets on decline, and optionally on sustained (flat) values.- Overrides:
nextValuein classPeriodCounterRTIndicator- Parameters:
prevValue- the previous raw input valuenewValue- the current raw input value- Returns:
- the gain amount, or 0 if no gain
-
isResetPeriodsOnSustain
public boolean isResetPeriodsOnSustain()
-