[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Relative Volatility Index By Donald Dorsey



PureBytes Links

Trading Reference Links

Help with RVI coding.
I have coded 2 versions of the RVI, one version gives correct 
signals only on day data and not on weekly data.
I am trying to backtest a system using the RVI.
I would like the RVI to display the same values as in Metastock 8.0.
My code is obiously incorrect,but where?

_SECTION_BEGIN("AH RVI as Metastock 8.0");
{

tp = Optimize("RVI Periods ", 14, 2, 100, 5 ); 
sdh = Optimize("STD Deviation Periods ", 10, 2,100, 5 ); 
rv=Param("RVI Periods :",14,-50,200,1);
rvs=Param("STD Deviation Periods :",10,-50,200,1);
Color=ParamColor("color", colorBlue );
style=ParamStyle("style" );


tp= rv;
sdh=StDev(H,rvs);
changeh= ROC(H,1);
Zh=Wilders(IIf(changeh>0,sdh,0),tp);
Yh=Wilders(IIf(changeh<0,sdh,0),tp);
RSh=Zh/Yh;
rvih=100-(100/(1+RSh));
sdl=StDev(L,rvs);
changel= ROC(L,1);
Zl=Wilders(IIf(changel>0,sdl,0),tp);
Yl=Wilders(IIf(changel<0,sdl,0),tp);
RSl=Zl/Yl;
rvil=100-(100/(1+RSl));
rviall=(rvih+rvil)/2;
SetChartOptions(0,0,chartGrid0|chartGrid100);

Plot (rviall,_DEFAULT_NAME(),Color,style);

}
_SECTION_END();

---------------------------------------------------------------------
-------------
---------------------------------------------------------------------
-------------------------
---------------------------------------------------------------------
-----
_SECTION_BEGIN("AH New RVI as Metastock 8.0");
{
Color=ParamColor("color", colorBlue );
style=ParamStyle("style" );
rv=Param("RVI Periods :",14,-50,200,1);
rvs=Param("STD Deviation Periods :",10,-50,200,1);
IIf (H<H-1,xh=StDev(H,10),0);
IIf (H>H-1,x=StDev(H,10),0);
IIf (L<L-1,yl=StDev(L,10),0);
IIf (L>L-1,y=StDev(L,10),0);
zz=MA(xh,14);
z=MA(x,14);
aa=MA(yl,14);
a=MA(y,14);

upavup=((z*(14-1))+z)/14;
dnavup=((zz*(14-1))+zz)/14;
upavdow=((aa*(14-1))+aa)/14;
dnavdow=((a*(14-1))+a)/14;
RVIUP=(upavup+dnavup)/2;
RVIdown=(upavdow+dnavdow)/2;
rviorig=100*(rviup/(rviup+rvidown));
rvinew=(rviup+rvidown)/2;
Plot (rviorig,_DEFAULT_NAME(),Color,style);
}
_SECTION_END();

Regards Anne






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/DldnlA/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/