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

Re: RWI different in Ami and Mstock



PureBytes Links

Trading Reference Links

Hello, Thanks,
I copy below the most important part of previous mail, RWI is clear 
now in Amibroker.

http://groups.yahoo.com/group/amibroker/message/2850


RwiHi and RwiLo functions in AmiBroker are calculated as follows 
(this is pseudo-code not AFL): 
1. First partial RwiLoN and RwiHiN values are calculated when N 
changes from minperiods to maxperiods 
(Ref - gives the value N periods back as in AFL, and ATR is Average 
True Range (as in AFL) and SQRT is a square root function ) 
RwiHiN = ( High - Ref( Low, -N ) ) / ( ATR( N ) * SQRT( N ) ); 
RwiLoN = ( Ref( High, -N ) - Low ) / ( ATR( N ) * SQRT( N ) ); 
2. Then the maximum of calculated values are taken (in this example 
minperiods = 10; maxperiods = 15 ) 
RwiHi( 10, 15 ) = max( RwiHi10, RwiHi11, RwiHi12, RwiHi13, RwiHi14, 
RwiHi15 ); 
RwiLo( 10, 15 ) = max( RwiLo10, RwiLo11, RwiLo12, RwiLo13, RwiLo14, 
RwiLo15 ); 
3. Rwi oscillator is a difference between RwiHi and RwiLo 
As you can see from the formulas given in (1) it may happen that the 
value is negative, for example 
in a strong downtrend RwiHiN for all specified N can be negative - 
current highs are lower than Lows N periods ago. 
Metastock obviously adds something like that: 
RwiHi = Max( RwiHi, 0 ); 
RwiLo = Max( RwiLo, 0 ); 
essentially not allowing negative values at all. I doubt if this is 
correct. But you may use this correction 
in your code: 
MSrwilo = Max( RWILo( 8, 20 ), 0 ); 
MSrwihi = Max( RWIHi( 8, 20 ), 0 ); 

////////////////////////

Actually ATR( N) is a *moving average* of true ranges over the N 
bars. 
The only difference is that ATR uses Wilders averaging: 
ATR( N ) = Wilders( TrueRange, N ) = Wilders( ATR( 1 ), N );


> Richard,
> 
> There is a series of messages on this subject beginning at msg 2836.
> 
> Ed
> 
> --- In amibroker@xxxx, "Richard Alford" <richard.alford@xxxx> wrote:
> > No problem, Tomasz. Actually, I only want to know what AB uses 
> when you get a chance. I attempted to search the archives but to 
no 
> avail.
> > 
> > Enjoy your trip,
> > 
> > Richard