Class LossRTIndicator
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.LossRTIndicator
- All Implemented Interfaces:
ClockAware, PeriodCounter, Resettable, RTIndicator
Tracks negative price changes (losses) between consecutive updates.
Returns the loss amount (prevValue - newValue) as a positive number when the
price decreases, and 0 otherwise. Maintains a period counter tracking consecutive
loss periods. The counter can optionally reset when the price stays flat.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected doubleprotected doubleinitValue(double initValue) Non periodic init valuebooleanprotected doublenextValue(double prevValue, double newValue) Computes the loss 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
-
LossRTIndicator
public LossRTIndicator() -
LossRTIndicator
-
-
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 loss between consecutive values. Returns the positive difference when the price decreases (and increments the period counter), or 0 when flat or rising. Period counter resets on gains, and optionally on sustained (flat) values.- Overrides:
nextValuein classPeriodCounterRTIndicator- Parameters:
prevValue- the previous raw input valuenewValue- the current raw input value- Returns:
- the loss amount (positive), or 0 if no loss
-
isResetPeriodsOnSustain
public boolean isResetPeriodsOnSustain()
-