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

Notification

Icon
Error

Options
Go to last post Go to first unread
Traetey  
#1 Posted : Wednesday, May 12, 2010 12:34:06 PM(UTC)
Traetey

Rank: Member

Groups: Registered, Registered Users
Joined: 3/22/2010(UTC)
Posts: 16

Hello peeps,

I've been looking for a logical NOT operator in MetaStock, so far -- no luck :p How do you handle this in your code?

IF ( I-do-not-want-this ; 0 ; 1) ?

Any help would be greatly appreciated!

Regards,
Traetey
v.trader  
#2 Posted : Wednesday, May 12, 2010 1:54:10 PM(UTC)
v.trader

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/26/2009(UTC)
Posts: 76
Location: Toronto, Canada

Hi, If you are using a binary value (e.i. could only have 2 values - TRUE or FALSE), Metastock recognizes 0 as False and everything else as TRUE (usually 1). So for instance x:=Mov(C,20,S)>Mov(C,30,S); x=0 Is the same thing as saying "I don't want the short MA to be above the long MA". As for non-binary values (e.i. any real number) you could use the "" operator which means not equal to. So for example, Mov(C,20,S)Mov(C,30,S) Would mean that the 2 MA are different in actual values. You see my logic here, you could basically manipulate most of the logical and comparison operators to achieve a state where you make Metastock make sure that one thing is NOT in some way related to another.Hope this helps. VT
mstt  
#3 Posted : Wednesday, May 12, 2010 2:03:50 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 Traetey

Here are a couple of examples.

If( (condition I do not want) = 0 , 1 , 0); – If() returns a TRUE when condition is false.

If( (condition I do not want) , 0 , 1); – If() also returns a TRUE when condition is false.

If you only require a TRUE or FALSE result you can omit the If() function entirely – a statement made without a qualifying logical value (=0 or =1, =FALSE or =TRUE) is assumed to represent a TRUE (or 1) unless specifically stated otherwise. The If() function is useful when neither if the possible values returned are 0 or FALSE but it’s just unnecessary padding if the result must be TRUE and FALSE – any logical expression will do that anyway.

( condition I do not want ) = FALSE;

This above expression will return a logical TRUE when your condition is FALSE, and the expression below will return a logical FALSE when your condition is FALSE (no surprises there).

( condition I do not want )

As you can see, reversing the logical state of an expression (from TRUE to FALSE or vice versa ) is simply a matter of adding “=0” or “=FALSE” to that expression. There is no need to add “=1” or “=TRUE” when looking for a TRUE result as MetaStock assumes a TRUE is expected unless stated otherwise.

Hope this doesn’t confuse you too much.

Roy

Traetey  
#4 Posted : Wednesday, May 12, 2010 3:47:47 PM(UTC)
Traetey

Rank: Member

Groups: Registered, Registered Users
Joined: 3/22/2010(UTC)
Posts: 16

This is exactly what I've been looking for, thank you both !
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.