Rank: Newbie
Groups: Registered, Registered Users Joined: 7/31/2013(UTC) Posts: 2
|
Hi All,
I have recently purchased MetaStock and am trying to find my way around. The software is really powerful and has some fantastic features.
I have been trying to write an explorer formula to run through a list of instruments and identify those where a candlestick reversal pattern has taken place in the last three days and the Stochastic is in overbought territory.
When I run the following I get unexpected results and I am unsure why:
x:=3; Alert(ShootingStar(),x) OR Alert(EngulfingBear(),x) OR Alert(DarkCloud(),x) AND Stoch(8,3) > 80
The fomula correctly identifies instruments with the candlestick patterns but still includes instruments where the Stoch is below 80.
Have I used the OR and AND combination incorrectly?
Thanks and regards,
Terry
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi Terry
Yes it does seem that you're using the OR operator incorrectly. As written by you there are three elements, and any one of the three TRUE will return a TRUE result.
x:=3; Alert(ShootingStar(),x) OR Alert(EngulfingBear(),x) OR ( Alert(DarkCloud(),x) AND Stoch(8,3) > 80 );
I suspect what you're trying to achieve is as follows, but do your own testing.
x:=3; ( Alert(ShootingStar(),x) OR Alert(EngulfingBear(),x) OR Alert(DarkCloud(),x) ) AND Stoch(8,3) > 80;
Roy
PS: I have not tested any version so don't rely on my changes. What you can do is creat a new indicator for each version, plot them on a relevant chart and see which one is correct visually. You can't "see" what's going on in an exploration so it pays to switch to the indicator format where's it's much easier to see what's going on.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 7/31/2013(UTC) Posts: 2
|
Thanks Roy.
Amazing what a big difference the humble pair of brackets can make!
I should have seen that :o(
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi Terry
No need to feel bad about it. I've been working with MetaStock for about 14 years and didn't fully understand this issue (precedence of AND relative to OR) until a lot more recently. It's in the manual but I continued to make sure by using more brackets than was strictly necessay.
Roy
|
|
|
|
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.