Rank: Newbie
Groups: Registered, Registered Users Joined: 2/6/2007(UTC) Posts: 2
|
Hi everybody,
I'm trying to call an external function dependig on specific condition.
Unfortunately the external function is called wheter the condition is true or false.
This is my code, used in indicator or expert advisor:
If(C>Ref(C,-1),ExtFml("MyDll.Myfunction",1,4),1)
Is it possible to let the function be called only if the condition is true?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 3/7/2005(UTC) Posts: 1,346
|
hey ftwim..... your code looks okay to me, unless your MyDll.Myfunction is returning just a 1 or 0 itself...... what type of value is your fml returning.....
the code below basically its similar to yours ..... in the first string i've used 1 as you and in the second i changed to mov(c,10,s)......h
------------------------------
{plots the extfml if c>ref(c,-1) and a 1 otherwise}
If(C>Ref(C,-1), ExtFml( "myMA2.SMA", C , 20) ,1)
------------------------------
----------------
{plots the extfml if c>ref(c,-1) and the mov(c,10,s) otherwise}
If(C>Ref(C,-1), ExtFml( "myMA2.SMA", C , 20) ,Mov(C,10,S))
-----------------
|
|
|
|
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 FTWim
I think the external formula will be called whether or not its result is used. Typically MS will calculate the innermost parentheses of any expression first, and in your If() function I think that means the external formula.
I would organize the formula a little differently to see if I could get the required functionality. A little lateral thinking sometimes goes a long way when solving MS problems.
Try this. It might not be the solution you’re looking for (your question is a little light on detail) but it’s worth a try.
X:=ExtFml("MyDll.Myfunction",1,4);
If(C>Ref(C,-1),X,1);
Roy
MetaStock Tips & Tools
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 2/6/2007(UTC) Posts: 2
|
Thank you, your solution seems to work properly.
|
|
|
|
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.