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

Notification

Icon
Error

Options
Go to last post Go to first unread
FTWim  
#1 Posted : Tuesday, February 6, 2007 3:46:27 PM(UTC)
FTWim

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?

hayseed  
#2 Posted : Wednesday, February 7, 2007 11:25:42 AM(UTC)
hayseed

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))

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

mstt  
#3 Posted : Wednesday, February 7, 2007 8:12:45 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 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

FTWim  
#4 Posted : Thursday, February 8, 2007 3:22:46 AM(UTC)
FTWim

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.