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

[EquisMetaStock Group] Re: RSI Calculation



PureBytes Links

Trading Reference Links

Kenneth,

I can verify that Wilders used Wilders smoothing when he wrote the 
RSI. Wilders is a variant form of exponential smoothing.

The difference is in the lookback periods.

Here's a quicky formula to confirm this. Not precise but very close:

N:=Input("Periods",1,250,25);
R:=(N/2)+1;
Mov(CLOSE,N,E);
Wilders(CLOSE,R);

Notice that the Wilders formula uses a different lookback period that 
is calculated in the "R" array?basically half plus one. If you change 
the lookback period you will notice a larger variance at shorter 
periods. It is due to the initial seeding at the beginning of the 
data. 


Roy Larsen has discussed this many times before and again a simple 
search of our archived messages will yield a number of emails to this 
very point. His website is :

www.metastocktips.co.nz

There you will find a number of indicators that he has written. His 
link along with others that will help you can be found in our links 
section. A RSI written by Roy is listed below.  


{RSI Indicator}
N:=Input("Periods",2,99,10);
A:=Close; 
B:=Ref(A,-1);
U:=Wilders(If(A>B,A-B,0),N);
D:=Wilders(If(A<B,B-A,0),N);
100-(100/(1+(U/D)));


Hope this helps,


Preston




--- In equismetastock@xxxxxxxxxxxxxxx, "antoinesax" <kennethmetz@xxx> 
wrote:
>
> Preston, Thanks for your reply.
> 
> I'm not sure which method Wilder used. But it seems that MS 
actually 
> does use EMA smoothing in computing the RSI. I state this for the 
> following reason.
> 
> When I directly compare my spreadsheet calculations of RSI (where 
> EMAs are used but are computed recursively) with MS's results for 
SPY 
> from 1993 through the present (using a 14 bar period), the greatest 
> percentage error is 0.0003%. On that basis, it most definitely 
> appears that MS also uses EMAs in its internal calculation.
> 
> I'm wondering if anyone among the MS development community is 
> participating in this group who can definitively state which method 
> is used?
> 
> KM
> 
> 
> --- In equismetastock@xxxxxxxxxxxxxxx, pumrysh <no_reply@> wrote:
> >
> > Kenneth,
> > 
> > The major flaw that I see with your code is the method of 
smoothing 
> > which should be Wilder's not Exponential. There are literally 
> dozens 
> > of ways to write the code. You can find some here:
> > http://trader.online.pl/MSZ/e-0-tytulowa-r.html
> > You may also search our archived messages and find a few that are 
> not 
> > there and may work even better.
> > 
> > Preston
> > 
> > 
> > 
> > --- In equismetastock@xxxxxxxxxxxxxxx, "antoinesax" 
<kennethmetz@> 
> > wrote:
> > >
> > > Prior to exploring some variations for RSI, I thought it best 
to 
> > first 
> > > verify my own coding for this indicator in comparison with 
> > MetaStock's 
> > > calculation. 
> > > 
> > > Much to my surprise, the results differed widely when applied 
to 
> > SPY 
> > > (from first data in 1993 through present date). Although 
> generally 
> > > zigging and zagging in the same direction, the two differ 
> > > significantly with ratio (my own code vs MS) varying from 
around 
> > 0.5 
> > > to 1.3.
> > > 
> > > On the other hand, a spreadsheet version nearly matches MS, 
> > suggestion 
> > > a problem in the MS coding. The only difference in the two 
> versions 
> > is 
> > > that I used recursive formulas in the spreadsheet to implement 
> the 
> > > EMA, whereas I simply used the Mov(C, N, E) function in MS.
> > > 
> > > Can someone point out the error in the code shown below?
> > > 
> > > 
> > > Thanks,
> > > 
> > > KM
> > > 
> > > PS. Please note that the code uses the most logical definition 
of 
> > RSI, 
> > > which is mathematcially equivalent to the standard version 
using 
> RS 
> > > that was (maybe) computationally simpler three decades ago when 
> > this 
> > > indicator was invented...
> > > 
> > > 
> > > ===========================================
> > > 
> > > Npds := Input("Periods",1,5000,14);
> > > Chng := C - Ref(C,-1);
> > > Adv := If(Chng>0,Chng,0);
> > > Dec := If(Chng<0,-Chng,0);
> > > AvgAdv := Mov(Adv,Npds,E); 
> > > AvgDec := Mov(Dec,Npds,E); 
> > > RSItest := 100*AvgAdv/(AvgAdv+AvgDec);
> > > 
> > > 
> > > RSItest
> > >
> >
>




------------------------------------

Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

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

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