RelativeVigorIndex — Relative Vigor Index
Does the close finish strong relative to the bar’s range? The body (close − open) over the range (high − low), both weighted across four bars and then summed over the window. The premise: in an uptrend, closes cluster near highs.
Signature
RelativeVigorIndex(period, on=<source>)| Argument | Type | Required | Notes |
|---|---|---|---|
period |
int Param or literal | Yes | Summation window. Default 10, bounds 1–400. |
on= |
symbol | No | Source symbol. Defaults to the trade symbol. Reads open, high, low, close. |
Formula
$$ \text{RVI} = \frac{\sum_n \text{SWMA}(C - O)}{\sum_n \text{SWMA}(H - L)} $$
where SWMA is the symmetric 1/2/2/1 four-bar weighting; the signal line applies the same weighting to the RVI.
Warmup
period + 3 bars.
Reading the value
rvi.rvirvi.signalrvi.rvi > rvi.signalMulti-value: cannot be chained onto or crossed.
Example
class RviCross(Strategy): """Trade the RVI/signal crossover.""" trade = Symbol() sizing = FixedCapital()
def execute(self): rvi = RelativeVigorIndex(10, on=self.trade) if rvi.rvi > rvi.signal and self.trade.is_flat: self.buy(self.trade, reason="RVI above signal") if rvi.rvi < rvi.signal and self.trade.is_long: self.sell(self.trade, self.trade.position, reason="RVI below signal")Notes
- John Ehlers’ Relative Vigor Index.