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
|
|
|
|
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"));
|
|
|
|
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
|
|
|
|
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.)
|
|
|
|
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
|
|
|
|
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!
|
|
|
|
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
|
|
|
|
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)
|
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.