Forex
Google

Go Back   Forex Trading > Discussion Areas > Metatrader 4
Forex Forum FAQ Members List Calendar Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

 
 
LinkBack Thread Tools
 
Old 01-27-2006, 01:02 AM
charliev charliev is offline
Junior Member
 
Join Date: Jan 2006
Posts: 25
charliev is on a distinguished road
#import

This is GREAT board to learn MQL!!! I'd like to learn more about using Windows .DLL's in my MQL4 code... I downloaded coderguru's MQL4 Course (EXCELLENT!) but need more info. Can anyone make any suggestions?

-charliev
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-03-2006, 12:50 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Lightbulb External functions

Quote:
Originally Posted by charliev
This is GREAT board to learn MQL!!! I'd like to learn more about using Windows .DLL's in my MQL4 code... I downloaded coderguru's MQL4 Course (EXCELLENT!) but need more info. Can anyone make any suggestions?

-charliev
This is my brief article about using imprort funtion:

//+------------------------------------------------------------------+
//| Exteranl functions 1 .mq4 |
//| Copyright Coders Guru |
//| http://www.metatrader.info |
//+------------------------------------------------------------------+

#property
copyright "Copyright Coders Guru"
#property
link "somewhere"

#import
"mylib.ex4"
int MyExtFunction(int value,int value2);
#import


//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+

int
start()
{
//----

int result = MyExtFunction(10,20);
Alert ( result);
//----

return(0);
}
//+------------------------------------------------------------------+

In the code above to use an external function resides in a MQL4 library file we have taken two steps:

1- Importing the external function from the library.
2- Using (calling) the function like any MQL4 function.

Importing the external function:

To be able to use the external function from your code you have to import it to your code.

Importing the function takes three lines of code as you see above:

#import
"mylib.ex4"

This is the first import line, we use the #import keyword followed by the library name, the line doesn't end with semi-colon.

int MyExtFunction(int value,int value2);

Then in the second line you declare the function very like the normal functions by writing the type of returned value followed by the function name then the parameters of the function and their types. Without this declaration your program will not know anything about the external function. You can import as many function as you want, in this case you write every function in a separate line.
The declaration line must ends with semi-colon.

#import

To tell the compiler of MQL4 that you have finished your importing you have to write another line contains the #import keyword, but in this case without an external file.
Note: You use only one #import line to end all the opened import lines, for example:

#import "mylib.ex4"
int MyExtFunction(int value,int value2);
#import "mylib2.ex4"
double MyExtFunction2(double value3);
#import

Calling the external function:

If you have written right import block lines like the above description, you can call the external function very like calling any normal function in MQL4 program. In our program we called the MyExtFunction like this:

int result = MyExtFunction(10,20);
Alert ( result);

We passed the numbers 10 and 20 to the function and assigned the returned value to the integer variable result.
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-03-2006, 10:10 PM
kamyar's Avatar
kamyar kamyar is offline
Senior Member
 
Join Date: Dec 2005
Location: Iran
Posts: 635
kamyar is on a distinguished road
hi codersguru

would you help us.please see the link.
Gartley 222

Last edited by kamyar : 02-03-2006 at 10:14 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-05-2006, 03:30 PM
charliev charliev is offline
Junior Member
 
Join Date: Jan 2006
Posts: 25
charliev is on a distinguished road

Thanks codersguru!!!
-c
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-06-2007, 04:02 PM
jbwyme jbwyme is offline
Junior Member
 
Join Date: Feb 2007
Posts: 5
jbwyme is on a distinguished road
MQL/DLL Importing Error Help (Error 127)

I am trying to use a DLL I created but everytime I try to use a function I get "cannot call function 'myFunc' from dll 'test.dll' (error 127)"

does anyone know what this error means?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-06-2007, 05:59 PM
Luke_P Luke_P is offline
Junior Member
 
Join Date: Nov 2006
Posts: 26
Luke_P is on a distinguished road
maybe you should post your code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 02-07-2007, 12:04 AM
dwmcqueen dwmcqueen is offline
Member
 
Join Date: Dec 2006
Posts: 69
dwmcqueen is on a distinguished road
What compiler are you using? Did you manually create a def file (in Visual Studio) or pass the correct parameters to the compiler (in MingW)?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 04-06-2008, 05:12 AM
WNW's Avatar
WNW WNW is offline
Senior Member
 
Join Date: Feb 2006
Location: Motown, USA
Posts: 370
WNW is on a distinguished road
Can a script be run from an EA?

Can an EA run a script?

I need an EA that says, "if there are no open or pending orders, run "myscript".

Any help appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 04-06-2008, 07:07 AM
newdigital newdigital is offline
Administrator
 
Join Date: Sep 2005
Posts: 15,129
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
I moved your post to this thread but I am not sure about: may be this issue is not related ...
The other thread is here How to connect multiple EA’s in under 15 minutes!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import custom DLL The_N Expert Advisors - Metatrader 4 1 05-30-2006 09:09 PM
#import questions TheExponential Questions 5 12-09-2005 04:56 AM


All times are GMT. The time now is 11:00 AM.