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

Notification

Icon
Error

Options
Go to last post Go to first unread
Alan R  
#1 Posted : Friday, January 20, 2012 9:31:02 AM(UTC)
Alan R

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 9/23/2009(UTC)
Posts: 51

The following code will count the number of days in which the close is higher than the day before. How do I code this efficiently so that I can count the number of up day's for any number of days chosen?

N1:= If(CLOSE > Ref(CLOSE,-1),1,0);
N2:= If(Ref(CLOSE,-1) > Ref(CLOSE,-2),1,0);
N3:= If(Ref(CLOSE,-2) > Ref(CLOSE,-3),1,0);
N4:= If(Ref(CLOSE,-3) > Ref(CLOSE,-4),1,0);
N5:= If(Ref(CLOSE,-4) > Ref(CLOSE,-5),1,0);

Total:= N1 + N2 + N3 + N4 + N5;

Total;

Alan R  
#2 Posted : Friday, January 20, 2012 9:42:12 AM(UTC)
Alan R

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 9/23/2009(UTC)
Posts: 51

Never mind I figured it out.

nmbr:= 5;

Mov((CLOSE > Ref(CLOSE,-1)),nmbr,S)*nmbr;

"That was dumb question!!!"

wabbit  
#3 Posted : Friday, January 20, 2012 4:36:29 PM(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)
Do a search on the forum and look for posts explaining the Boolean nature of MS and the way evaluations are performed; then check out the Sum() function.


wabbit [:D]

Alan R  
#4 Posted : Thursday, January 26, 2012 1:28:02 PM(UTC)
Alan R

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 9/23/2009(UTC)
Posts: 51

Sum(CLOSE > Ref(CLOSE,-1),5);

Thanks Wabbit!

That's better.

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.