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

Notification

Icon
Error

Options
Go to last post Go to first unread
schizzmo1  
#1 Posted : Thursday, July 15, 2010 8:42:19 AM(UTC)
schizzmo1

Rank: Newbie

Groups: Registered, Registered Users
Joined: 7/15/2010(UTC)
Posts: 2

Hello,

Newbie here. I am looking for some assistance with an explorer formula I have been trying to write.

I am basically trying to identify stocks which are consistently gaining or falling over a period of 30 days. So for LONGS the exploration would identify stocks which have risen in 22 or more days out of 30, and vice versa for SHORTS.

The formula, (not the most elegant I admit!) looks something like this at this stage:

higher := 0;
lower := 0;

If( White(), higher = higher + 1, lower = lower + 1);
If( Ref(White(),-1) , higher = higher + 1, lower = lower + 1);
If( Ref(White(),-2) , higher = higher + 1, lower = lower + 1);
If( Ref(White(),-3) , higher = higher + 1, lower = lower + 1);
If( Ref(White(),-4) , higher = higher + 1, lower = lower + 1);
If( Ref(White(),-5) , higher = higher + 1, lower = lower + 1);
If( Ref(White(),-6) , higher = higher + 1, lower = lower + 1);.....{and so on upto -30 days}

Higher > 22

----------------------

It seems to me that the problem I am having is that the 'higher' variable is not being updated correctly (Ihigher = higher + 1). What is the correct code for adding 1 to the existing variable?

Many thanks for any assistance

vienna  
#2 Posted : Thursday, July 15, 2010 9:08:10 AM(UTC)
vienna

Rank: Advanced Member

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

Hi,

the if function in metastock is working in an other way than in most languages, you can only fill in values or functions in the "then" cause but not variable declarations.

e.g.:
x:=if(a=1,1,0); {is working}
if(a=1,x:=1,x:=0); {is wrong!!!}

Your example must be something like:
higher:=If(White(),1,0);
lower:=If(White(),0,1);
higher30:=Sum(higher,30);
higher30>22
or to see all variables in the chart use:
higher:=If(White(),1,0);
lower:=If(White(),0,1);

higher30:=Sum(higher,30);
higher;
higher30;
higher30>22







schizzmo1  
#3 Posted : Thursday, July 15, 2010 9:26:27 AM(UTC)
schizzmo1

Rank: Newbie

Groups: Registered, Registered Users
Joined: 7/15/2010(UTC)
Posts: 2

Excellent. Works very well except I will need to play around with the numbers of days checked and the ratio of risers/falls.

Thanks Vienna. Heres hoping it makes me a few quid :)

vienna  
#4 Posted : Friday, July 16, 2010 6:22:01 AM(UTC)
vienna

Rank: Advanced Member

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

Metastock provides also an optimize function which enables you to test different settings in the enhanced system tester. There you can test different values for variables. This helps a lot because you don't have to play with changing the values manually, but there is also the dangernes of overfitting...

In the manual or in the internet (eg. http://www.advantagetrad...imizing_systems_eng.html ) you can find a lot about system optimizer..

best regards
vienna
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.