RVI

Calculates the Relative Vigor Index indicator.

Accepts the following parameters:

Parameter NameTypeDefault ValueNotes
periodNumber10-

Returns: Series<Number>

RVI is a built-in function - you can use it directly. Below is an example implementation:

1 function RVI(period = 10):
2 co = close - open[1]
3 hl = high - low
4 numerator = Sum(co + 2 * co[1] + 2 * co[2] + co[3], period)
5 denominator = Sum(hl + 2 * hl[1] + 2 * hl[2] + hl[3], period)
6
7 numerator / denominator if denominator != 0 else numerator