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

Notification

Icon
Error

Options
Go to last post Go to first unread
brackenwood  
#1 Posted : Saturday, April 9, 2005 5:52:42 PM(UTC)
brackenwood

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 4/9/2005(UTC)
Posts: 2

I am trying to learn to code formulas. It was going well until I tried what seems like a simple task. I want to check if a moving average is going in a positive or negative direction since the day before. I have tried mov(c,10,e)>ref(mov(c,10,e),-1) and ROC(Mov(C,10,E),1,$)>0. I have tried absolute values with the same success rate. I can see the values plotted on the chart and it seems it would be a simple effort to check one against the last. Also, I have looked through the book and I didn't see mention of a NOT condition. Is there a way to check for: a AND b OR c but NOT d? thanks
henry1224  
#2 Posted : Saturday, April 9, 2005 10:53:26 PM(UTC)
henry1224

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)
What you are trying to do is create a binary formula, -1 for when both conditions are positive,1 for when both conditions are negative, and 0 for when both conditions are not in sync A:=mov(c,10,e); B:=ROC(Mov(C,10,E),1,$); D:=If(A>Ref(A,-1) and B>0,-1,If(A<Ref(A,-1) and B<0,1,0)); D;
henry1224  
#3 Posted : Saturday, April 9, 2005 11:09:20 PM(UTC)
henry1224

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)
Highlights Long A:=mov(c,10,e); B:=ROC(Mov(C,10,E),1,$); D:=If(A>Ref(A,-1) and B>0,-1,If(A<Ref(A,-1) and B<0,1,0)); D=-1 Short A:=mov(c,10,e); B:=ROC(Mov(C,10,E),1,$); D:=If(A>Ref(A,-1) and B>0,-1,If(A<Ref(A,-1) and B<0,1,0)); D=1 Symbols Long Entry A:=mov(c,10,e); B:=ROC(Mov(C,10,E),1,$); D:=If(A>Ref(A,-1) and B>0,-1,If(A<Ref(A,-1) and B<0,1,0)); D=-1 and Ref(D,-1)>-1 Short Entry A:=mov(c,10,e); B:=ROC(Mov(C,10,E),1,$); D:=If(A>Ref(A,-1) and B>0,-1,If(A<Ref(A,-1) and B<0,1,0)); D=1 and Ref(D,-1)<1
henry1224  
#4 Posted : Saturday, April 9, 2005 11:27:04 PM(UTC)
henry1224

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)
Highlights Long A:=mov(c,10,e);A1:=Mov(C,50,E); B:=ROC(Mov(C,10,E),1,$); D:=If(A>Ref(A,-1) and B>0,-1,If(A<Ref(A,-1) and B<0,1,0)); F:=If(D=-1 and C>A1,-1,If(D=1 and C<A1,1,0)); F=-1 Short A:=mov(c,10,e);A1:=Mov(C,50,E); B:=ROC(Mov(C,10,E),1,$); D:=If(A>Ref(A,-1) and B>0,-1,If(A<Ref(A,-1) and B<0,1,0)); F:=If(D=-1 and C>A1,-1,If(D=1 and C<A1,1,0)); F=1 Out A:=mov(c,10,e);A1:=Mov(C,50,E); B:=ROC(Mov(C,10,E),1,$); D:=If(A>Ref(A,-1) and B>0,-1,If(A<Ref(A,-1) and B<0,1,0)); F:=If(D=-1 and C>A1,-1,If(D=1 and C<A1,1,0)); F=0 Symbols Long entry A:=mov(c,10,e);A1:=Mov(C,50,E); B:=ROC(Mov(C,10,E),1,$); D:=If(A>Ref(A,-1) and B>0,-1,If(A<Ref(A,-1) and B<0,1,0)); F:=If(D=-1 and C>A1,-1,If(D=1 and C<A1,1,0)); F=-1 and Ref(F,-1)>-1 Long Exit A:=mov(c,10,e);A1:=Mov(C,50,E); B:=ROC(Mov(C,10,E),1,$); D:=If(A>Ref(A,-1) and B>0,-1,If(A<Ref(A,-1) and B<0,1,0)); F:=If(D=-1 and C>A1,-1,If(D=1 and C<A1,1,0)); F=0 and Ref(F,-1)=-1 Short Entry A:=mov(c,10,e);A1:=Mov(C,50,E); B:=ROC(Mov(C,10,E),1,$); D:=If(A>Ref(A,-1) and B>0,-1,If(A<Ref(A,-1) and B<0,1,0)); F:=If(D=-1 and C>A1,-1,If(D=1 and C<A1,1,0)); F=1 and Ref(F,-1)<1 Short Exit A:=mov(c,10,e);A1:=Mov(C,50,E); B:=ROC(Mov(C,10,E),1,$); D:=If(A>Ref(A,-1) and B>0,-1,If(A<Ref(A,-1) and B<0,1,0)); F:=If(D=-1 and C>A1,-1,If(D=1 and C<A1,1,0)); F=0 and Ref(F,-1)=1
brackenwood  
#5 Posted : Sunday, April 10, 2005 2:14:02 AM(UTC)
brackenwood

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 4/9/2005(UTC)
Posts: 2

I looked through the Primer and blew right past the chapter on nested conditions, didn't think I would need it. Thanks for the code, I am still going through it to learn how to expand on it. This is an excellent start. Thanks again for the reply. :D
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.