Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 3/20/2006(UTC) Posts: 53
|
Moving Averages of "Variable"
Hi.
I would like to set a indicator like the following:
[color=red:de328b6530]Variable:=Input("Please enter a variable like C, V, MACD()");[/color]
Mov(Variable, 25, E)
However it won't work.
What did I miss? #-o
|
|
|
|
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)
|
The Input() function can only receive numeric values.
To solve your situation, nest some If() statements to produce the desired result in the variable, e.g.
x:=Input("Use 1=C, 2=V, 3=MACD()",1,3,1);
x:=If(x=1,C,If(x=2,V,If(x=3,MACD(),0)));
Mov(x, 25, E);
Hope this helps.
wabbit :D
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 3/20/2006(UTC) Posts: 53
|
wabbit wrote:The Input() function can only receive numeric values.
To solve your situation, nest some If() statements to produce the desired result in the variable, e.g.
x:=Input("Use 1=C, 2=V, 3=MACD()",1,3,1);
x:=If(x=1,C,If(x=2,V,If(x=3,MACD(),0)));
Mov(x, 25, E);
Hope this helps.
wabbit :D
Does Metastock only accept numeric value?
Is there any function which accepts string/text?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 3/19/2005(UTC) Posts: 2,995
Was thanked: 14 time(s) in 10 post(s)
|
You could use GV.dll to set and retrieve variables by string names, but it wouldn't serve to improve the example above. The input function only accepts numeric data.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 3/20/2006(UTC) Posts: 53
|
g_stockman wrote:You could use GV.dll to set and retrieve variables by string names, but it wouldn't serve to improve the example above. The input function only accepts numeric data.
Do you mean I can type the string and GV.dll will transfer it into numeric value?
Sound good!
Where can I get GV.dll?
PS: I managed to get this file from http://www.metastocktools.com/
But it has no manual/instruction.
How to use?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 3/19/2005(UTC) Posts: 2,995
Was thanked: 14 time(s) in 10 post(s)
|
I mean that you can transfer numeric data into a variable with a string name outside of MS. Here is the syntax:
ExtFml( "GV.Clear")
ExtFml( "GV.GetVar", Variable Name)
ExtFml( "GV.SetVar", Variable Name, Expression)
There are several examples that use this code available here on the forum.
|
|
|
|
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.