External functions
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:
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.int MyExtFunction(int value,int value2);
#import "mylib2.ex4"
double MyExtFunction2(double value3);
#importCalling 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:
Thanks codersguru!!!
-c
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
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

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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