Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 6/12/2007(UTC) Posts: 32
|
I am working on adpating ATR and am looking for the orgnial formula. Thanks to Oztrader I was able to get the math eqaution but putting this into Metaspeak I found the results from my formula and Metastocks ATR() are very different. I need help to find out where I am going wrong.
The math formula for Average Ture Range is
Formula:
I am guessing that the "n" is for periods and "[-1]" is previous day and "[0] is current day
My formula is
{TR:TureHigh Take subtract Ture Low for current day,
TRp:TureHigh subtract TureLow previous day,
AT: Average True Range}
Period:=14; TR:=If(H>Ref(C,-1),H,Ref(C,-1))-(If(L<Ref(C,-1),L,C)); TRp:=If(Ref(H,-1)>Ref(C,-2),Ref(H,-1),Ref(C,-2))-If(Ref(L,-1)<Ref(C,-2),Ref(L,-1),Ref(C,-2)); AT:=((TRp*(Period-1))+TR)/Period; AT;
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
I looked on the web for a definition, looks like there are several, so how about:
a1:=(H-L); a2:=(H-Ref(C,-1)); a3:=(L-Ref(C,-1)); a4:=If((a1>a2),a1,a2); a5:=If((a4>a3),a4,a3); a6:=Mov(a5,10,E); a6
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 11/18/2007(UTC) Posts: 96 Location: HK
|
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 12/14/2009(UTC) Posts: 140 Location: Austria
|
as I remember - atr from metastock works with wilders mov
n:=14; tr:=Max(Max(Abs(H-L),Abs(H-Ref(C,-1))),Abs(Ref(C,-1)-L)); atr:=Mov(tr,2*n-1,E);
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi Laisze
I think the formula you posted would be more aptly named "True Range" since there is no smoothing associated with it. As Vienna has said the MetaStock ATR() function uses Wilders Smoothing. To employ other smoothing methods (EMA for example) it's usual to smooth ATR(1) with the required method - Mov(ATR(),Periods,E).
Roy
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
The last expression of my post should be Mov(ATR(1),Periods,E). Sorry for any confusion.
Roy
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.