Code for RVI

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
sradke
Posts: 8
Joined: 27 Jun 2009

Code for RVI

Postby sradke » 24 Feb 2010

Is anyone aware of a way to get the RVI indicator for MultiCharts?
Thanks

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Code for RVI

Postby TJ » 24 Feb 2010

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?

sradke
Posts: 8
Joined: 27 Jun 2009

Postby sradke » 24 Feb 2010

I am referring to the relative volatility index

sradke
Posts: 8
Joined: 27 Jun 2009

Postby sradke » 25 Feb 2010

My mistake, I am referring to the Relative Vigor Index.

geektrader
Posts: 100
Joined: 17 Jul 2009
Location: Germany

Postby geektrader » 25 Feb 2010

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;

sradke
Posts: 8
Joined: 27 Jun 2009

Postby sradke » 25 Feb 2010

Thank You, Geektrader!!

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Relative Vigor Index (Ehlers)

Postby TJ » 26 Feb 2010

Relative Vigor Index (Ehlers)
Attachments
RVI.doc
(62.5 KiB) Downloaded 612 times

Laurent
Posts: 159
Joined: 20 Nov 2010
Location: France
Has thanked: 76 times
Been thanked: 34 times

Re: Code for RVI

Postby Laurent » 26 Jan 2011

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?

Laurent
Posts: 159
Joined: 20 Nov 2010
Location: France
Has thanked: 76 times
Been thanked: 34 times

Re: Code for RVI

Postby Laurent » 11 Feb 2011

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

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Code for RVI

Postby TJ » 11 Feb 2011

there you go...

Relative Volatility Index

and

RVII function
(numeric, autodetect)
Attachments
RVII.txt
RVII function
(788 Bytes) Downloaded 807 times
Relative Volatility Index.txt
Relative Volatility Index
(690 Bytes) Downloaded 817 times

Laurent
Posts: 159
Joined: 20 Nov 2010
Location: France
Has thanked: 76 times
Been thanked: 34 times

Re: Code for RVI

Postby Laurent » 11 Feb 2011

The formula should be good I presume!

Thanks a lot TJ! :)

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Code for RVI

Postby TJ » 11 Feb 2011

The formula should be good I presume!

Thanks a lot TJ! :)
You are welcome.


Return to “User Contributed Studies and Indicator Library”