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

Notification

Icon
Error

Options
Go to last post Go to first unread
ageitalia  
#1 Posted : Friday, October 21, 2011 8:06:41 AM(UTC)
ageitalia

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 6/16/2006(UTC)
Posts: 47
Location: Italy

Thanks: 6 times
Hi everyone, I'm looking for the correct syntax of a formula giving me each day the lowest value among two formulas. In other words, let's say I developed two custom formula named "Alpha" and "Bravo". So, each day a third formula will show the lowest among Alpha and Bravo. I figured something like llv(fml("Alpha"); fml("Bravo")), but it didn't work. So I wrote If(fml1
jjstein  
#2 Posted : Friday, October 21, 2011 10:39:43 AM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
If(FML("A")<FML("B"),FML("A"),FML("B"));

mstt  
#3 Posted : Friday, October 21, 2011 12:54:08 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)

or
Min(Fml("Alph"),Fml("Bravo"));

I'm assuming that you want to do this with EOD data. If by any chance you want a daily result from intraday data then the concept is the same but some supporting code would be needed.

Roy
jjstein  
#4 Posted : Friday, October 21, 2011 1:45:06 PM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
Touche! Always nice to have alternatives...

Now, for an extra brownie point on today's edition of "Ask the Expert": Which is faster?

(I have no idea.)

mstt  
#5 Posted : Friday, October 21, 2011 2:38:25 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 Johnathan

It's Saturday morming and raining, so rather than being out digging the garden I'm sitting here looking to claim an extra brownie point. My guess is that two Fml() calls trumps four. What say you?

Roy
jjstein  
#6 Posted : Friday, October 21, 2011 10:24:22 PM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
Hmmm. Obviously, there must be something to this faster-than-light business, else how can I be getting your message on Friday night, from Saturday morning? Although the weather's the same...except my garden is put to bed for the winter.

As for whether FML calls or the difference between MIN and IF take more time, with stopwatch in hand and double-running each Exploration to eliminate the effect of disk-buffering, I get just over 4 seconds for 4 FML calls, just under 4 seconds for 2 FML calls on the S&P 500.

_temp A: C>O
_temp B: C>Mov(C,10,S)

Exploration A filter: If(Fml("temp A")<Fml("temp B"),Fml("temp A"),Fml("temp B"));
Exploration B filter: Min(Fml("temp A"),Fml("temp B"));

Without FML, both under 3 secs, but about 1/10 sec faster on B.

Exploration A filter:
A:=C>O;
B:=C>Mov(C,10,S);
If(A<B,A,B);


Exploration B filter:
A:=C>O;
B:=C>Mov(C,10,S);
Min(A,B);

You win a KEWPIE doll!UserPostedImage

mstt  
#7 Posted : Sunday, October 23, 2011 3:20:31 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 Johnathan

Ah, the wonders of modern technology. Luckily the International Date Line is all it takes for me to write this on Monday morning for you to get it on Sunday afternoon.

To get realistic timing figures for MS code execution one would probably start with real-life formulas and run them on 1000-2000 bars of data. Nobody (not even me) really cares if 1 or 13 bars are loaded and take 3.something seconds to run across the S&P500. However, the difference between 30 and 60 seconds with more substantial formulas and 2000 data bars could be significant enough to prompt some users to look for a more efficient way of writing the code. If there's one thing I detest it's having to wait longer than is really necessary for Metastock to finish a system test or exploration.

This discussion started with a question about how to find the lower of two values. My response was not offered as a faster alternative to the method you suggested, and the If() method can easily be set up to run at the same speed as the Min() method. My real message is that there are almost always several solutions to any MetaStock problem.

Roy
jjstein  
#8 Posted : Sunday, October 23, 2011 6:20:28 PM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
>>Luckily the International Date Line is all it takes for me to write this on Monday morning for you to get it on Sunday afternoon.

And here I thought maybe you had one of these.


>>My real message is that there are almost always several solutions to any MetaStock problem.

Yeah, someday, I will get to the point where at least two solutions will suggest themselves, and I can shave the problem with Occam's razor.

Users browsing this topic
Guest (Hidden)
Similar Topics
SMI Cross and Lowest Value (Formula Assistance)
by simurg76 5/9/2016 11:15:07 AM(UTC)
Taking the highest and lowest value of an indicator for each time period (Formula Assistance)
by ageitalia 2/8/2011 1:28:15 AM(UTC)
Finding the lowest value of an indicator in a specific time frame (Formula Assistance)
by Strategist 10/6/2007 7:12:31 AM(UTC)
Highest and lowest value (MetaStock)
by lpm80 4/23/2007 4:32:14 AM(UTC)
Examining lowest value in different time frames [RESOLVED] (Formula Assistance)
by dieselpr 7/30/2005 12:30:46 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.