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

[EquisMetaStock Group] Re: RSI Calculation



PureBytes Links

Trading Reference Links

Ken,

You are more than welcome! The RSI is one of my favorite indicators. 
It took us a bit to realize the differences between the two smoothing 
methods. I have to laugh everytime I read that someone is using 
shorter lookback periods with success. Seems Wilder knew that already.

While I have your attention and since you mentioned recussion, let me 
ask for your help. A few days ago we were discussing the Rainbow/RMO 
indicator. The method used to smooth the indicator was a recursive 
smoothing. Normally this wouldn't be so tedious but in the case of 
the Rainbow/RMO it is a moving average of a moving average.......and 
on. We can code the indicator but not in a way that allows for any 
lookback changes without reproducing the complete indicator, 
basically its hardwired. Just wondering if you might have some 
thoughts on ways to simplify the indicator.


Preston

     

--- In equismetastock@xxxxxxxxxxxxxxx, "antoinesax" <kennethmetz@xxx> 
wrote:
>
> Thanks, Preston.
> 
> I had just come to a similar conclusion. 
> 
> After reviewing Wilder's original publication, I recognized that he 
> used a form of exponential smoothing with factors 1/N and 1 - 
(1/N), 
> where N is the RSI period. In contrast, the usual EMA uses factors 
2/
> (M + 1) and 1 - 2/(M+1), where M is the EMA period. Equating the 
> corresponding factors produces the results that M = 2*N -1 and N = 
(M 
> + 1)/2.
> 
> Using Mov(C, M, E) instead of Mov(C, N, E) in my original code 
> renders identical results to MS's RSI.
> 
> Ken
> 
> 
> --- In equismetastock@xxxxxxxxxxxxxxx, pumrysh <no_reply@> wrote:
> >
> > 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@> 
> > 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/