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
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;
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
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