Class RelativeVigorIndexRTIndicator

java.lang.Object
com.wualabs.qtsurfer.engine.indicators.core.AbstractRTIndicator
com.wualabs.qtsurfer.engine.indicators.momentum.pro.RelativeVigorIndexRTIndicator
All Implemented Interfaces:
Resettable, CacheableRTIndicator, RichRTIndicator<MarketSnapshot>, RTIndicator

public class RelativeVigorIndexRTIndicator extends AbstractRTIndicator implements RichRTIndicator<MarketSnapshot>, CacheableRTIndicator
Relative Vigor Index (RVI) with O(1) per-tick computation.

Measures conviction of price movement using OHLC data:

  numerator   = (1*(close-open) + 2*(close[1]-open[1]) + 2*(close[2]-open[2]) + 1*(close[3]-open[3])) / 6
  denominator = (1*(high-low)   + 2*(high[1]-low[1])   + 2*(high[2]-low[2])   + 1*(high[3]-low[3]))   / 6
  RVI = SMA(numerator, period) / SMA(denominator, period)

Uses a 4-element circular buffer for the symmetric weighted average (weights: 1,2,2,1), then smooths with SMA. Default period: 10. Returns 0 when denominator SMA is 0.

  • Constructor Details

    • RelativeVigorIndexRTIndicator

      public RelativeVigorIndexRTIndicator()
    • RelativeVigorIndexRTIndicator

      public RelativeVigorIndexRTIndicator(int period)
  • Method Details

    • signature

      public String signature()
      Description copied from interface: CacheableRTIndicator
      This instance's math identity — equal signatures must mean identical value series for identical input.
      Specified by:
      signature in interface CacheableRTIndicator
      Returns:
      the identity, or null when this instance cannot state one (an unidentifiable source, a mode the implementation does not model) and must therefore compute live
    • isReady

      public boolean isReady()
      Description copied from interface: RTIndicator
      Returns whether this indicator has received enough data to produce meaningful values.

      During the warmup period, RTIndicator.getValue() may return 0 or a partial estimate that should not be used for trading decisions. Once this method returns true, the indicator's output is statistically valid.

      The default implementation returns true for backward compatibility. Indicators with warmup requirements should override this method.

      For composite indicators (e.g. Bollinger Bands, MACD), readiness is determined by the slowest internal component.

      Specified by:
      isReady in interface RTIndicator
      Returns:
      true if the indicator has completed its warmup period
    • reset

      public void reset()
      Specified by:
      reset in interface Resettable
      Overrides:
      reset in class AbstractRTIndicator
    • requiresBarData

      public boolean requiresBarData()
      Whether this indicator's result is only meaningful over per-bar OHLCV data.

      The distinction matters because a RichRTIndicator<MarketSnapshot> accepts a TickerSnapshot just as happily as a KlineSnapshot — and on the ticker path volume, high, low and open are the exchange's 24-hour rolling statistics, not this tick's bar. Nothing throws: OBV silently accumulates a 24h volume figure over and over, ATR reads a 24h range as if it were one bar's. The numbers look plausible and mean nothing, which is the worst failure mode of the three.

      Indicators that return true are flagged once per (indicator, instrument) when bound on the ticker path — see InstrumentMapTickerSourceRTIndicator. Scalar indicators (SMA/EMA/RSI over a single price) are unaffected and default to false.

      true: this indicator reads per-bar OHLCV, which the ticker path does not carry.

      Specified by:
      requiresBarData in interface RichRTIndicator<MarketSnapshot>
      Returns:
      true if this indicator needs real bar data; false by default
    • updateFrom

      public double updateFrom(MarketSnapshot snap)
      Description copied from interface: RichRTIndicator
      Updates the indicator from a full market snapshot. Returns the new value so callers can chain (matching RTIndicator.update(double)'s contract).
      Specified by:
      updateFrom in interface RichRTIndicator<MarketSnapshot>
    • updateOhlc

      public double updateOhlc(double open, double high, double low, double close)
      Updates with OHLC prices directly.
      Parameters:
      open - the open price
      high - the high price
      low - the low price
      close - the close price
      Returns:
      the computed RVI value
    • update

      public double update(double newValue)
      Specified by:
      update in interface RTIndicator
      Overrides:
      update in class AbstractRTIndicator