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

Notification

Icon
Error

Options
Go to last post Go to first unread
vaughn  
#1 Posted : Sunday, September 11, 2005 2:37:26 AM(UTC)
vaughn

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
wabbit  
#2 Posted : Sunday, September 11, 2005 3:00:17 AM(UTC)
wabbit

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
Patrick  
#3 Posted : Sunday, September 11, 2005 4:57:50 AM(UTC)
Patrick

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 ;) ...
vaughn  
#4 Posted : Monday, September 12, 2005 9:12:11 PM(UTC)
vaughn

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
Patrick  
#5 Posted : Monday, September 12, 2005 9:25:12 PM(UTC)
Patrick

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.