logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Gregor  
#1 Posted : Saturday, October 23, 2010 6:28:56 AM(UTC)
Gregor

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:
 src=

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;

johnl  
#2 Posted : Saturday, October 23, 2010 7:17:36 PM(UTC)
johnl

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
Laisze  
#3 Posted : Sunday, October 24, 2010 8:33:32 PM(UTC)
Laisze

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 11/18/2007(UTC)
Posts: 96
Location: HK

Here is the ATR formula from metastocktools: x1:=ValueWhen(2,1,C); Max(H-L,Max(Abs(x1-H),Abs(x1-L))) http://www.metastocktools.com/MetaStock/RATR.txt
vienna  
#4 Posted : Monday, October 25, 2010 1:05:58 AM(UTC)
vienna

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);
mstt  
#5 Posted : Monday, October 25, 2010 3:08:56 AM(UTC)
mstt

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
mstt  
#6 Posted : Monday, October 25, 2010 3:11:14 AM(UTC)
mstt

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.