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

Notification

Icon
Error

Options
Go to last post Go to first unread
Icko  
#1 Posted : Thursday, May 13, 2010 2:40:28 AM(UTC)
Icko

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/30/2008(UTC)
Posts: 9

I can't get around MEDIAN function in Metastock. It is available in Excel like standard function but not in MS. Can somebody help please Note: It is not median price (h+l)/2!
v.trader  
#2 Posted : Thursday, May 13, 2010 7:02:41 AM(UTC)
v.trader

Rank: Advanced Member

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

Hi, Metastock has a function "MP()" which as the Formula Primer says is the media price... I'm not sure exactly how it's calculated... Also there is the function "typical()" which is (H+L+C)/3... However, (H+L)/2 should give you the median price since by definition a median number is a number exactly half-way through a number sequence... Cheers VT
Icko  
#3 Posted : Thursday, May 13, 2010 9:09:00 AM(UTC)
Icko

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/30/2008(UTC)
Posts: 9

Thanks for your input v.trader but that is not what I'm looking for. MP is median price and can be used for example in Moving averages instead of close. In meta stock MP=(h+l)/2 What I need is MEDIAN function f like here http://en.wikipedia.org/wiki/Median. Thanks for your input again
vienna  
#4 Posted : Friday, May 14, 2010 1:50:43 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

hi,

i think there is not such function in metastock and it's also not easy to programm it for longer periods. In my point of view it would be only possible to program it with the developer kit for a lot of sample values...

For which period do you need it?
Icko  
#5 Posted : Monday, May 17, 2010 7:21:23 AM(UTC)
Icko

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/30/2008(UTC)
Posts: 9

Hi vienna I need it for 30min, 60min and maybe daily. I know that is not available as single standing function. Thanks for your reply
vienna  
#6 Posted : Monday, May 17, 2010 8:43:22 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

.. and for how many values (samples)?
I think for 5-6 values (periods) back it would be possible to calculate.. but more will end in problems because of the limit of number of characters in a metastock function...

the general problem ist that in metastocks-language loops are not implemented..

maybe it's possible to get over the limit with the use of the gv.dll and setting some variables with

ExtFml( "gv.SetVar", "x1", C);
ExtFml( "gv.SetVar", "x2", Ref(C,-1));
ExtFml( "gv.SetVar", "x3", Ref(C,-2));
:

all the values to sort them in a sub function again and again...


Icko  
#7 Posted : Monday, May 17, 2010 11:51:00 PM(UTC)
Icko

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/30/2008(UTC)
Posts: 9

Thanks vienna Looks like the easiest will be to pull data into excel and do calculation there. Will try your code for sure. Thanks for your efforts
vienna  
#8 Posted : Tuesday, May 18, 2010 6:58:01 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

Hi Icko,

I have implemented such functionality for 5 days... you will need 3 custom functions/formulas to use it:

vienna_sort_1:
{(c) Sort algorithm for metastock by vienna - ts}
x1:=ExtFml( "gv.GetVar", "x1");
x2:=ExtFml( "gv.GetVar", "x2");
y1:=If(x1=Max(x1,x2),x1,x2);
y2:=If(x1=Max(x1,x2),x2,x1);
x1:=y1;x2:=y2;
ExtFml( "gv.SetVar", "x1", x1);
ExtFml( "gv.SetVar", "x2", x2);

vienna_sort_0:
{(c) Sort algorithm for metastock by vienna - ts}
v1:=ExtFml( "gv.GetVar", "v1");
v2:=ExtFml( "gv.GetVar", "v2");
v3:=ExtFml( "gv.GetVar", "v3");
v4:=ExtFml( "gv.GetVar", "v4");
v5:=ExtFml( "gv.GetVar", "v5");


ExtFml( "gv.SetVar", "x1", v1);
ExtFml( "gv.SetVar", "x2", v2);
Fml("vienna_sort_1");
v1:=ExtFml( "gv.GetVar", "x1");
v2:=ExtFml( "gv.GetVar", "x2");
ExtFml( "gv.SetVar", "x1", v2);
ExtFml( "gv.SetVar", "x2", v3);
Fml("vienna_sort_1");
v2:=ExtFml( "gv.GetVar", "x1");
v3:=ExtFml( "gv.GetVar", "x2");
ExtFml( "gv.SetVar", "x1", v3);
ExtFml( "gv.SetVar", "x2", v4);
Fml("vienna_sort_1");
v3:=ExtFml( "gv.GetVar", "x1");
v4:=ExtFml( "gv.GetVar", "x2");
ExtFml( "gv.SetVar", "x1", v4);
ExtFml( "gv.SetVar", "x2", v5);
Fml("vienna_sort_1");
v4:=ExtFml( "gv.GetVar", "x1");
v5:=ExtFml( "gv.GetVar", "x2");

ExtFml( "gv.SetVar", "v1", v1);
ExtFml( "gv.SetVar", "v2", v2);
ExtFml( "gv.SetVar", "v3", v3);
ExtFml( "gv.SetVar", "v4", v4);
ExtFml( "gv.SetVar", "v5", v5);
vienna_sort:
{(c) Sort algorithm for metastock by vienna - ts}


tmp:=ExtFml( "gv.SetVar", "v1", C);
tmp:=ExtFml( "gv.SetVar", "v2", Ref(C,-1));
tmp:=ExtFml( "gv.SetVar", "v3", Ref(C,-2));
tmp:=ExtFml( "gv.SetVar", "v4", Ref(C,-3));
tmp:=ExtFml( "gv.SetVar", "v5", Ref(C,-4));

tmp:=Fml("vienna_sort_0");
tmp:=Fml("vienna_sort_0");
tmp:=Fml("vienna_sort_0");
tmp:=Fml("vienna_sort_0");
tmp:=Fml("vienna_sort_0");

v1:=ExtFml( "gv.GetVar", "v1");
v2:=ExtFml( "gv.GetVar", "v2");
v3:=ExtFml( "gv.GetVar", "v3");
v4:=ExtFml( "gv.GetVar", "v4");
v5:=ExtFml( "gv.GetVar", "v5");

v3;
{
v3 .. median value
v1 .. highest value
v5 .. lowest value
}

To use it.. only use "vienna_sort" on your security..

best
ts

PS: gv.dll will be needed - you can find it in this 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.