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

Notification

Icon
Error

Options
Go to last post Go to first unread
Pcons  
#1 Posted : Friday, November 23, 2007 8:46:25 AM(UTC)
Pcons

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/23/2007(UTC)
Posts: 9

Hello everybody,

I want to make a condition that is true if the ATR is ascending. In the condition I can only get the value of the actual ATR. But how can I find out the direction of the indicator (descending, ascending etc...)? Somehow it must be related to older data, but i dont know how to put this in a formula.

kr

florian

hayseed  
#2 Posted : Friday, November 23, 2007 12:47:15 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey florian.....you can use the ref function .....h

//------------------------------moving up----------------------------

a:= ATR(40 ) ;

a > Ref(a,-1)

//--------------------------------------------------------------------

or

//----------------------------moving down--------------------------

a:= ATR(40 ) ;

a < Ref(a,-1)

//------------------------------------------------------------------

Pcons  
#3 Posted : Sunday, November 25, 2007 3:42:06 PM(UTC)
Pcons

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/23/2007(UTC)
Posts: 9

many thanks, i'll try that tomorrow!
Pcons  
#4 Posted : Monday, November 26, 2007 11:16:12 AM(UTC)
Pcons

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/23/2007(UTC)
Posts: 9

Ok another Question: The "40" in ATR(40) is always related to the period selected in the chart. For example, if I choose the 15 Min Period, the ATR is the average of the true ranges over the past 40 (15min) periods. Am I right?

If yes, is it correct that ref(a,-1) delivers the value of the ATR one period ago, in words: the ATR over the past 41 periods excluding the actual one. is that correct?

If yes, then ref(a,-1) would only deliver the difference between the actual ATR and the ATR one period ago. So how can I find out if the ATR is ascending since x periods f..e.?

hayseed  
#5 Posted : Monday, November 26, 2007 11:54:24 AM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey pcons..... yes you are correct on both points..... atr bounces so much that some sort of smoothing must be employed.... my code was just a quick example and used atr(40) to help smooth some....

you could use the same //---- a > ref(a, -10) ------- to find how the current bars atr compares to atr from 10 bars ago..... that would still be somewhat shakey and might not truely reflect whether the atr is rising/falling......

you could further smooth the atr by applying a moving average to it..... the code below will plot the moving average of the atr or a binary wave showing whether the current value is greater than the previous value..... plot =1 for moving average, plot=2 for binary wave.....

you could also place a variable for the -1 to be able to use -5, five bars ago, and so on..... there are other methods but this might be the eaiest to code......h

//-------------------------------------

ma:=Input("maperiods",2,100,10);
avtr:=Input("atrperiods",2,100,10);
plot:=Input("plot",1,2,1);

a:=Mov(ATR(avtr),ma,S);
aa:=If(a>Ref(a,-1),1,0);

//-----------------------------------

henry1224  
#6 Posted : Monday, November 26, 2007 5:37:05 PM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)

Try to use the sum function over 3 or 5 days

ma:=Input("maperiods",2,100,10);
avtr:=Input("atrperiods",2,100,10);
plot:=Input("plot",1,2,1);

a:=Mov(ATR(avtr),ma,S);
aa:=If(Sum(a>Ref(a,-1),5)>2,1,If(Sum(a<Ref(a,-1),5)>2,-1,0));

hayseed  
#7 Posted : Monday, November 26, 2007 6:13:25 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey henry .....thanks.... that does work a whole lot better.... h

hey pcons.... eariler my mind was on the markets here and in my haste i left off the line of the code.... i've added it here to henry's version which is far better than mine..... h

//---------------------------------------------

ma:=Input("maperiods",2,100,10);
avtr:=Input("atrperiods",2,100,10);
plot:=Input("plot",1,2,1);

a:=Mov(ATR(avtr),ma,S);

aa:=If(Sum(a>Ref(a,-1),5)>2,1,If(Sum(a<Ref(a,-1),5)>2,-1,0));

If(plot=1,a,aa) {i left off this line above}

//---------------------------------------------

Pcons  
#8 Posted : Wednesday, November 28, 2007 2:54:42 AM(UTC)
Pcons

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/23/2007(UTC)
Posts: 9

wow thanks for the support! I'try it out as soon as i can!
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.