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
|
|
|
|
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)
//------------------------------------------------------------------
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 11/23/2007(UTC) Posts: 9
|
many thanks, i'll try that tomorrow!
|
|
|
|
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.?
|
|
|
|
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);
//-----------------------------------
|
|
|
|
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));
|
|
|
|
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}
//---------------------------------------------
|
|
|
|
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.