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

Notification

Icon
Error

Options
Go to last post Go to first unread
Plank  
#1 Posted : Wednesday, July 31, 2013 6:14:17 AM(UTC)
Plank

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

mstt  
#2 Posted : Wednesday, July 31, 2013 5:03:24 PM(UTC)
mstt

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.
Plank  
#3 Posted : Thursday, August 1, 2013 8:21:13 AM(UTC)
Plank

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(

mstt  
#4 Posted : Thursday, August 1, 2013 6:58:42 PM(UTC)
mstt

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.