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

Notification

Icon
Error

Options
Go to last post Go to first unread
MetaLearner  
#1 Posted : Monday, May 4, 2009 10:01:33 PM(UTC)
MetaLearner

Rank: Newbie

Groups: Registered, Registered Users
Joined: 5/5/2009(UTC)
Posts: 1

Hi,

I'm just trying to clarify my understanding about setting variables in a custom indicator.

Is there no way to set the value of a variable based on a condition. e.g., If condition A is true then variable B is equal to 1. If condition B is true then variable B is equal to 2. Something like that in Metastock formula language. It does not seem possible but I wanted to confirm. Thanks.
wabbit  
#2 Posted : Monday, May 4, 2009 10:18:10 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Hi MetaLearner,

Welcome to the Forum.

The MS Users Manual and the free Equis Formula Primer are the best places to start learning about the MS forumla language. You will find in there details instructions and exercises on how to assign values to variables and how to use the If() function.

Your description uses A and B (twice) so in sticking with the problem description, it goes something like this:

B:=A=TRUE;
B:=If(B,2,B);

Which is the same as:

B:=2*(A=TRUE);

If you meant something more along the lines of, "If condition A is true then variable X is equal to 1, otherwise, if condition B is true then variable X is equal to 2" this would be written using nested If()s

X:=If(A,1,If(B,2,0));

Almost anything is possible, but you have to be particulalry explicit when you are defining "anything".

You will find you get better support in having questions answered if you ask specific questions and use specific examples instead of (stealthy, I don't want people to know what I am up to, vague) scenarios using As and Bs.



Hope this helps.

wabbit [:D]

Users browsing this topic
Guest (Hidden)
Similar Topics
ASI.Ref does not work with variables (Forum Feedback)
by rible172@icloud.com 2/6/2021 9:50:00 AM(UTC)
Save / Restore global variables between sessions (Tips & Tricks)
by Henry R. Weber 11/29/2013 1:14:11 AM(UTC)
speed with variables (MetaStock)
by samjohn 9/11/2012 7:53:05 AM(UTC)
How to avoid/hide multiple formula variables in the list of custom indicators in the explorer? (Formula Assistance)
by Jaggi 5/8/2012 1:37:03 PM(UTC)
State variables in MetaStock (Formula Assistance)
by Systematic 11/8/2010 10:49:41 AM(UTC)
Unlimited number of variables (Product Wish List)
by Gregor 10/15/2010 10:14:01 AM(UTC)
passing variables in point and figure function (Formula Assistance)
by kalyan 7/27/2010 9:20:17 AM(UTC)
Dump variables in the final version? (Formula Assistance)
by blackcat54 4/14/2010 3:09:42 PM(UTC)
Global Variables - GV.dll - Anyone have a copy or equivalent? (Formula Assistance)
by forexweather 3/4/2009 2:06:14 PM(UTC)
Finding the minimum or maximum of three variables (Basic Coding Techniques)
by dovetree 2/8/2007 7:31:09 PM(UTC)
Using Securities as Global Variables (Similar to GV) (Formula Assistance)
by Spaceant 9/14/2006 11:11:15 AM(UTC)
Variables in Metastock (Formula Assistance)
by roymadhavi 1/23/2006 4:56:55 AM(UTC)
optimizer variables within fml() [RESOLVED] (MetaStock)
by verybadboy 11/8/2005 4:40:29 PM(UTC)
"Global" variables declaration (MetaStock Developer's Kit (MDK) Assistance)
by wabbit 5/15/2005 8:28:35 AM(UTC)
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.