help with coding

mrm

New Member
#1
I'm trying to code following line for exploration
close today> close yesterday and yesterday close <close 2 days ago
or close today>close yesterday+.50cents and close yesterday<close 2days ago minus-.50cents
and v>100000 and volume yesterday100000 and volume 2daysago 100000 and close today above $25.
this is how I wrote it

XH1=C>Ref(C,-1) AND Ref(C,-1)<Ref(C,-2) OR C>Ref(C,-1)+.5 AND Ref(C,-1)<Ref(C,-2)-.5 AND V>100000 AND Ref(V,-1)>100000 AND Ref(V,-2)>100000 AND C>25;
when I run exploration I see prices bellow $25 so I'm doing something wrong
Could please someone help me to code it correctly
Thank you for your help
Emil
 

mastermind007

Well-Known Member
#2
I'm trying to code following line for exploration
close today> close yesterday and yesterday close <close 2 days ago
or close today>close yesterday+.50cents and close yesterday<close 2days ago minus-.50cents
and v>100000 and volume yesterday100000 and volume 2daysago 100000 and close today above $25.
this is how I wrote it

XH1=C>Ref(C,-1) AND Ref(C,-1)<Ref(C,-2) OR C>Ref(C,-1)+.5 AND Ref(C,-1)<Ref(C,-2)-.5 AND V>100000 AND Ref(V,-1)>100000 AND Ref(V,-2)>100000 AND C>25;
when I run exploration I see prices bellow $25 so I'm doing something wrong
Could please someone help me to code it correctly
Thank you for your help
Emil
Emil, Good Effort. Your conditions are correct but you forgot to sprinkle parenthesis. Separate each conditions into separate vars if you have to so that u can understand.

XH1= (((C>Ref(C,-1)) AND (Ref(C,-1)<Ref(C,-2))) OR ((C>(Ref(C,-1)+.5)) AND (Ref(C,-1)<(Ref(C,-2)-.5)))) AND (V>100000) AND (Ref(V,-1)>100000) AND (Ref(V,-2)>100000) AND (C>25)

Both AND and OR are left associative and in this case u need to protect the OR.
 

mrm

New Member
#3
Thank you for your help
It work now great.O'boy that is lot of parentheses
Next time I will try to setup as different conditions .Maybe that will be better
Thanks again
Emil
 

mastermind007

Well-Known Member
#4
Thank you for your help
It work now great.O'boy that is lot of parentheses
Next time I will try to setup as different conditions .Maybe that will be better
Thanks again
Emil
Yes, I've added few more than necessary but its always safer to add extra than to deal with a hard-to-debug error
 

Similar threads