#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

 

External functions

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.
 

hi codersguru

would you help us.please see the link.

https://www.mql5.com/en/forum/173462

 

Thanks codersguru!!!

-c

 

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?

 

maybe you should post your code.

 

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

 

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.

 

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 https://www.mql5.com/en/forum/178506

 

Importing ea's

Im new and im frustrated. Can someone please help! Im currently working with VT Trader, but i want to switch to metatrader 4. I know that with vt trader I can import a trading system very easily. I have no idea how to import a trding system on mt4. Please help Thank you

 
marlow2007:
Im new and im frustrated. Can someone please help! Im currently working with VT Trader, but i want to switch to metatrader 4. I know that with vt trader I can import a trading system very easily. I have no idea how to import a trding system on mt4. Please help Thank you

You just need to copy the trading system (EA) .ex4 file in the /experts/ folder of your platform. And then start the platform, open a chart and apply the EA. That's all.

Hope that helps.

FerruFx

Reason: