Class RsiRTIndicator
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.momentum.RsiRTIndicator
- All Implemented Interfaces:
ClockAware, Resettable, CacheableRTIndicator, RTIndicator
public class RsiRTIndicator
extends AbstractDecorableIncrementalRTIndicator
implements CacheableRTIndicator
RSI RTIndicator
-
Constructor Summary
ConstructorsConstructorDescriptionRsiRTIndicator(int periods) RsiRTIndicator(int periods, boolean sma) RsiRTIndicator(int periods, RTIndicator indicator) RsiRTIndicator(int periods, RTIndicator indicator, boolean sma) Creates an RSI indicator with configurable averaging method. -
Method Summary
Modifier and TypeMethodDescriptionprotected doubledoubleprotected doubleinitValue(double initValue) Non periodic init valueprotected doublenextValue(double prevValue, double newValue) Computes the RSI value using the standard formula: RSI = 100 - (100 / (1 + RS)), where RS (Relative Strength) = averageGain / averageLoss.voidreset()Periods, averaging variant and source chain.protected com.google.common.base.MoreObjects.ToStringHelpertoString(com.google.common.base.MoreObjects.ToStringHelper ts) Methods inherited from class AbstractDecorableIncrementalRTIndicator
getIndicator, 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, withDisplayHint, withMeta
-
Constructor Details
-
RsiRTIndicator
public RsiRTIndicator() -
RsiRTIndicator
public RsiRTIndicator(int periods) -
RsiRTIndicator
public RsiRTIndicator(int periods, boolean sma) -
RsiRTIndicator
-
RsiRTIndicator
Creates an RSI indicator with configurable averaging method. When sma=true, uses SMA for gain/loss averaging (Cutler's RSI variant). When sma=false, uses MMA (Modified Moving Average, equivalent to Wilder's smoothing). Each gain/loss average wraps its own GainRTIndicator/LossRTIndicator to extract positive/negative price changes from the input stream.- Parameters:
periods- number of periods for the averaging windowindicator- optional decorated indicator to pre-process input valuessma- true for SMA-based averaging, false for MMA-based (Wilder's)
-
-
Method Details
-
reset
public void reset()- Specified by:
resetin interfaceResettable- Overrides:
resetin classAbstractDecorableIncrementalRTIndicator
-
getRelativeStrength
public double getRelativeStrength() -
signature
Periods, averaging variant and source chain.The variant is read back off the averaging indicator that was actually built rather than off a remembered constructor flag — Cutler's (SMA) and Wilder's (MMA) RSI produce different series for the same periods, and the object is the honest witness to which one this is.
- Specified by:
signaturein interfaceCacheableRTIndicator- Returns:
- the identity, or
nullwhen this instance cannot state one (an unidentifiable source, a mode the implementation does not model) and must therefore compute live
-
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 RSI value using the standard formula: RSI = 100 - (100 / (1 + RS)), where RS (Relative Strength) = averageGain / averageLoss. Handles edge cases: returns 0 when both are zero, 100 when only loss is zero (pure uptrend), 0 when only gain is zero (pure downtrend).- Overrides:
nextValuein classAbstractDecorableIncrementalRTIndicator- Parameters:
prevValue- the previous raw input value (used by gain/loss sub-indicators)newValue- the current raw input value- Returns:
- RSI value in the range [0, 100]
-
toString
protected com.google.common.base.MoreObjects.ToStringHelper toString(com.google.common.base.MoreObjects.ToStringHelper ts) - Overrides:
toStringin classAbstractRTIndicator
-