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

Notification

Icon
Error

Options
Go to last post Go to first unread
Manuel1990  
#1 Posted : Monday, April 23, 2012 8:11:17 AM(UTC)
Manuel1990

Rank: Newbie

Groups: Registered, Registered Users
Joined: 4/23/2012(UTC)
Posts: 4

Hi, I need to sum the 1-period % Rate of Change (on close price) between yesterday and today, 2 days ago and yesterday, 3 days ago and 2 days ago, and so on, but only if they are >0. Then I have to do the same with those Rate of change that are less than zero. And than I have to multiply them. for exaple: Day..............................ROC: 5/4 days ago..................2% 4/3 days ago.................-1% 3/2 days ago..................3% 2/1 days ago..................1% 1 day ago/today............-1.5% i need to calculate (6)*(-2.5) Does anybody know how to write a code trhat does this?? Thank you!!!
wabbit  
#2 Posted : Monday, April 23, 2012 9:06:20 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)
Code:

myroc:=roc(c,1,%);
up:=myroc>0;
dn:=myroc {less than} 0;

up:=sum(myroc*up,5);
dn:=sum(myroc*dn,5);

{plot}
up;
dn;
You might want to consider zero ROC? wabbit [:D]
Manuel1990  
#3 Posted : Monday, April 23, 2012 9:19:55 AM(UTC)
Manuel1990

Rank: Newbie

Groups: Registered, Registered Users
Joined: 4/23/2012(UTC)
Posts: 4

thank you very much. But I read the Formula Primer Guide, and there was no reference to something like "up:=myroc>0;", what does it do? what it means to declare a variable with a condition like ">0"?
wabbit  
#4 Posted : Monday, April 23, 2012 9:29:28 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)
MS evaluates the condition to return 1 if TRUE, 0 or FALSE otherwise. It's a much easier and faster way than : up:= if(myroc>0,1,0); wabbit [:D]
Manuel1990  
#5 Posted : Monday, April 23, 2012 9:35:39 AM(UTC)
Manuel1990

Rank: Newbie

Groups: Registered, Registered Users
Joined: 4/23/2012(UTC)
Posts: 4

oh!! I got it, brilliant, thanks!
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.