Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 3/16/2005(UTC) Posts: 93 Location: Maryland,US
|
I was reading up on the Aroon indicator that basically tells # of periods since highest high during that time frame. I was wondering if there is an indicator or code to show how many new highs have occurred in a given time period? The time period could be specified in the indicator / formula, [censored](14), or as a result of another query, BarsSince(a>b).
Since I am still new at coding, the only thing I can think of is like Patrick’s lesson 2. He used the SUM function to check successive days: sum(h>ref(h,-1),14), which works – I get the correct number of new highs. When I try to be clever with additional code to give me the sum periods since an event
A1:=BarsSince(a>b);
sum(h>ref(h,-1),A1)
I get an error telling me “This variable or expression must contain only constant data”
Is there a way to query for number of new highs in a time period that is not hard coded, ie. since an event?
Thanks
vm
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
The error message is because MS cannot deal with changing value provided to the Sum(what, howmany) function. This is why Patrick and Brad have created adaptive indicators. Maybe you could ask them to create an adaptive Sum() if it doesnt already exist.
Anyway, on to your immediate problem:
Have you tried to combine indicators, e.g.
count:=if(a<b AND h>ref(h,-1), PREV+1, PREV);
count;
could be a simple solution.... that might suit your purpose
BUT then we look a litle more carefully at what we are trying to do... We are trying to count the consecutive higher highs in a period. This looks like we could be employing Roy's signal counting latch:
{Signal Counter}
{© 2003 Roy Larsen}
{rlarsen@man.quik.co.nz}
{your a and b have been renamed x and y}
a:=(x>y) AND H>Ref(H,-1); {signal to count}
b:=H<=Ref(H,-1); {signal to reset}
i:=Cum(a+b>-1)=1;
f:=BarsSince(i OR a)<BarsSince(i OR b);
g:=Cum(a OR Cross(a,0.5))-ValueWhen(1,i OR (f AND
Alert(f=0,2)) OR (f=0 AND Alert(f,2)),Cum(a OR Cross(a,0.5)));
If(f,g+1,g);
See if this gets you on your way....
Hope this helps.
wabbit :D
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 9/8/2004(UTC) Posts: 2,266
Was thanked: 1 time(s) in 1 post(s)
|
Adaptive sum function already exists ;) ...
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 3/16/2005(UTC) Posts: 93 Location: Maryland,US
|
I thought I would update this post with the adaptive sum info. From my original cheesy made up formula:
A1:=BarsSince(a>b);
ExtFml("ForumDll.VarSUM",h>ref(h,-1),A1)
It works!
Thanks
vm
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 9/8/2004(UTC) Posts: 2,266
Was thanked: 1 time(s) in 1 post(s)
|
Glad it worked out for you :D
Thanks for the update
|
|
|
|
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.