Page 1 of 1

Code for RVI

Posted: 24 Feb 2010
by sradke
Is anyone aware of a way to get the RVI indicator for MultiCharts?
Thanks

Re: Code for RVI

Posted: 24 Feb 2010
by TJ
Is anyone aware of a way to get the RVI indicator for MultiCharts?
Thanks
are you referring to the Relative Vigor Index (Ehlers)?
or the Relative Volatility Index?

Posted: 24 Feb 2010
by sradke
I am referring to the relative volatility index

Posted: 25 Feb 2010
by sradke
My mistake, I am referring to the Relative Vigor Index.

Posted: 25 Feb 2010
by geektrader
Function: RVI

Code: Select all

Inputs: Length(NumericSimple);
Vars: Num(0),
Denom(0),
Count(0),
RVI(0),
Trigger(0);

Value1 = ((Close - Open) + 2*(Close[1] - Open[1]) + 2*(Close[2] - Open[2]) + (Close[3] - Open[3]))/6;
Value2 = ((High - Low) + 2 * (High[1] - Low[1]) + 2 * (High[2] - Low[2]) + (High[3] - Low[3]))/6;

Num = 0;
Denom = 0;
For count = 0 to Length -1 begin
Num = Num + Value1 [count];
Denom = Denom + Value2[count];
End;

If Denom <> 0 then RVI = Num / Denom;


Function: AdaptiveRVI

Code: Select all

Inputs: Price(numericseries), Len(numericsimple);
var:alpha(.07);
Vars: Smooth(0),Cycle(0),Q1(0),I1(0),DeltaPhase(0),MedianDelta(0),DC(0),InstPeriod(0),Period(0),
Count(0),Length(0),Num(0),Denom(0),RVI(0),MaxRVI(0),MinRVI(0);

alpha=Len/7142;

Smooth = (Price + 2*Price[1] + 2*Price[2] + Price[3])/6;
Cycle=(1-.5*alpha)*(1-.5*alpha)*(Smooth-2*Smooth[1]+Smooth[2])+2*(1-alpha)*Cycle[1]-(1-alpha)*(1-alpha)*Cycle[2];
If currentbar<7 then Cycle = (Price-2*Price[1]+Price[2])/4;
Q1=(.0962*Cycle+.5769*Cycle[2]-.5769*Cycle[4]-.0962*Cycle[6])*(.5+.08*InstPeriod[1]);
I1 = Cycle[3];
If Q1<>0 and Q1[1]<>0 then DeltaPhase=(I1/Q1-I1[1]/Q1[1])/(1+I1*I1[1]/(Q1*Q1[1]));
If DeltaPhase <0.1 then Deltaphase = 0.1;
If DeltaPhase >1.1 then Deltaphase = 1.1;
MedianDelta = Median(DeltaPhase,5);
If MedianDelta = 0 then DC = 15 else DC = 6.28318/MedianDelta + .5;
InstPeriod = .33*DC + .67*InstPeriod[1];
Period = .15*InstPeriod+.85*Period[1];
Length = intportion((4*Period+3*Period[1]+2*Period[3]+Period[4])/20);
Value1=((Close-Open)+2*(Close[1]-Open[1])+2*(Close[2]-Open[2])+(Close[3]-Open[3]))/6;
Value2=((High-Low)+2*(High[1]-Low[1])+2*(High[2]-Low[2])+(High[3]-Low[3]))/6;
Num = 0;
Denom = 0;
For Count = 0 to Length - 1 begin
Num = Num + Value1[count];
Denom = Denom + Value2[count]; End;
If Denom <> 0 then RVI = Num/Denom;

AdaptiveRVI=RVI *50 +50;

Function: RVIStochastic

Code: Select all

input: Length(numericsimple);
Var {Inputs}: delimiter(80);
Vars: Num(0),Denom(0),count(0),RVI(0),MaxRVI(0),MinRVI(0);
Value1 = ((Close - Open) + 2*(Close[1] - Open[1]) + 2*(Close[2] - Open[2]) + (Close[3] - Open[3]))/6;
Value2 = ((High - Low) + 2*(High[1] - Low[1]) + 2*(High[2] - Low[2]) + (High[3] - Low[3]))/6;
Num = 0; Denom = 0;
For count = 0 to Length - 1 begin
Num = Num + Value1[count];
Denom = Denom + Value2[count];
End;
If Denom <> 0 then RVI = Num / Denom;
MaxRVI = Highest(RVI, Length);
MinRVI = Lowest(RVI, Length);
If MaxRVI <> MinRVI then Value3 = (RVI - MinRvi) / (MaxRVI - MinRVI);
Value4 = (4*Value3 + 3*Value3[1] + 2*value3[2] + Value3[3]) / 10;
Value4 = 2*(Value4 - .5);

RVIStochastic=Value4 *50 +50;

Posted: 25 Feb 2010
by sradke
Thank You, Geektrader!!

Relative Vigor Index (Ehlers)

Posted: 26 Feb 2010
by TJ
Relative Vigor Index (Ehlers)

Re: Code for RVI

Posted: 26 Jan 2011
by Laurent
Thanks a lot Geektrader for the code!

How do you prefer to use them ?
With a signal line? with supports/resistances on the charts? as an oscillator?

Is there documentation about it?

Re: Code for RVI

Posted: 11 Feb 2011
by Laurent
In both case, the code posted is for the Relative Vigor Index.

Has someone coded the Relative Volatility Index?

For eSignal, the formula is there:
https://www.multicharts.com/support/bas ... le&id=1801

For Metastock, there:
http://trader.online.pl/MSZ/e-w-Relativ ... x_RVI.html

For TS, I have found this code, but do not think it's okay (with the loop).
http://freeforumzone.leonardo.it/discus ... dd=2132917

Re: Code for RVI

Posted: 11 Feb 2011
by TJ
there you go...

Relative Volatility Index

and

RVII function
(numeric, autodetect)

Re: Code for RVI

Posted: 11 Feb 2011
by Laurent
The formula should be good I presume!

Thanks a lot TJ! :)

Re: Code for RVI

Posted: 11 Feb 2011
by TJ
The formula should be good I presume!

Thanks a lot TJ! :)
You are welcome.