Create your own MetaTrader extension (dll) - page 5

 
prasxz:
is it possible make mt4 dll connected to web service and make php script to shows MT4 open position through a website , so people with no MT4 can see it from website in a realtime ?

Someone posted a while ago a MQL / MySQL example which worked great, the only issue with it is that most hosting companies do not allow remote access to their database servers. However if you did have full access and control to your server you would write an EA which would connect to your database and insert the data for each new order. Then from your website simply connect to the database and read the data ... In my opinion this would be the best approach.

Now a MT4 DLL can connect to a php script but I have never tried to pass the information from the EA to the Website, I was able to successfully do it the other way around though ... You would have to look into windows sockets, and functions such as HTTP_GET / HTTP_POST.

Patrick

 
Mistigri:
Not sure, that library looks familiar, are you using that to connect to a website? Have you tried using wininet.lib instead?

I don't think the issue here is the def file or your dll would not even load and work properly ... If you can provide more info ( ie some piece of the code you're using in the dll ) then maybe I can try to help.

Patrick

Hi Patrick!

I found the library and the source code here:

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

I placed there my post, but admin moved it into this thread...

Thanks!

 

Reading file located on the internet

Hi,

I want an EA to read a file, that's not located on the local machine but on the Internet.

FileOpen only works when the file is located in the metatrader directory.

I tired it with a c#-dll but get the error message "cannot call function".

Has s.o. an easy solution for this problem??

Thanks

 

Solution to Error 127 - cannot call function

Solution to Error 127 - cannot call function

Okay,

I finally got back to looking at this last night. The problem has to do with associating the wrong def file or nodef file with the dll.

This is how you fix it in Visual Studio 2008 Express -

1) Go to project, properties - or alt-F7

2) Go to Linker - double click on it and you get a drop down list

3) Select Input

4) Change the Module Definition File to be whatever you named your def file

Make sure it has the path and full name of the file - such as .\MyDef.def

In 2008 Express version, this is not generated automatically like in the professional versions.

This is the main culprit. There may be other linker/compiler issues that may still cause a problem. What you need to do is to load the ExportFunction example project that ships with Metatrader4. This is found in the experts/DllSample folder. Now go and look at its properties page by page, item by item, and everywhere that it says ExportSample, or ExpertSample, (or whatever it uses pertaining to its naming conventions) change your properties to match your own naming conventions. I went through and did this item by item, and then checked if I got the 127 error. I continued to get that error until the correct module definition file was explicity stated as a dependency. I am not saying that there may not be other things besides that, because I changed everything to match the sample, but once the def file was explicit, that fixed it.

Remember that the dll has to be in the lib folder. You have to have an mqh file in the include directory which explicity imports the dll, and lists the function names with parameters, return types, etc. And then in your indicator or expert you must include the header file. That should do it.

CodersGuru and Mistigri both have good examples on how to do this, but the non-professional Express versions do not explicity add the def file as a dependency, and that is the root of the problem all of us using the Express versions have. (At least it doesn't explicity add it when selecting the particular project to make that we who have the problem, selected.)

See attached image. Remember, you probably still want to make sure your compiler and linker values match those of the exportfunction sample that comes with Metatrader.

Regards,

MG

Files:
properties.jpg  75 kb
 
fedecosta:
Hi Patrick!

I found the library and the source code here:

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

I placed there my post, but admin moved it into this thread...

Thanks!

Sorry have not had a chance to look at it yet, I have been busy, but I did not forget and I will try to get back to you on that.

Peco07:

I want an EA to read a file, that's not located on the local machine but on the Internet.

You have 2 options, write a C# app that will connect to the website, write a data file on your computer and read it from MT4 or write a C++ dll that will connect to the website read the data ....

If you go the C# route, so far it seems way faster than the DLL route ... If you want to write a c++ DLL here is some code to help you get started.

MT4 DLL Web Connect | Mistigri

MG_1:

The problem has to do with associating the wrong def file or no def file with the dll.

This is how you fix it in Visual Studio 2008 Express -

Thanks for the info! If you don't mind I will reproduce some parts of your posts on my site...

 
Mistigri:
Thanks for the info! If you don't mind I will reproduce some parts of your posts on my site...

No problem, I know a lot of people go there to learn, so hopefully it will help the Express users and gnu, etc. users.

-MG

 
fedecosta:
Hello guys!

I have a problem trying to use this library.

I put them in metatrader\experts\library

I correctly define the path for the .def file

... but my EA print on the register this error: -65495

What can be the problem?

And, most, how to solve it?

Is it possible that the .def file can be corrupted?

Thanks in advance...

Hi Fedecosta,

Try to copy the def file directly under your c:\ drive ... That seems to work for me.

Note that this has nothing to do with DLL programming, it's specific to this EA...

Patrick

 
Mistigri:
Hi Tim,

When using dev-c++ the def file is generated for you automatically the problem is that you end up with function names that look like this :

EXPORTS

_Z11GetSMAArrayP8RateInfoiiPd@16 @ 1

_Z12GetHighValueP8RateInfoii = _Z12GetHighValueP8RateInfoii@12 @ 2

_Z12GetHighValueP8RateInfoii@12 @ 3

_Z13GetCloseValueP8RateInfoii = _Z13GetCloseValueP8RateInfoii@12 @ 4

_Z13GetCloseValueP8RateInfoii@12 @ 5

_Z11GetSMAArrayP8RateInfoiiPd = _Z11GetSMAArrayP8RateInfoiiPd@16 @ 6[/PHP]

Now you need to make sure you add the following check around your code

[PHP]

#ifdef __cplusplus

extern "C" {

#endif

#ifdef __cplusplus

}

#endif

Attached are the sample files I did for VS2008 but this time using dev-c++ ...

Hope this helps

do u mean that when write dll file,

the function in the def file should add _z12 at the begin?

that means in .mq4 file

call finction: get_max_deviation

then in .def file

the transfered function : _z12get_max_deviation???

what means for the @ number after the function name

thanks

 
Mistigri:

Attached are the sample files I did for VS2008 but this time using dev-c++ ...

Hope this helps

Attached Files

MistigriFX Sample Debug.mq4 (2.1 KB, 15 views)

MSFXDEV.zip (8.6 KB, 17 views )

I have dl your files , and compile the .cpp by the picture show

but occur error

do my compile method wrong , how do i compile it to dll ? (i am a c++ beginner ^^)

Files:
dev_dll.jpg  298 kb
 

DLL with shared function

Hello All and Mistigri,

i would like to know how to create shared function so that i don't have to copy-paste the functions on each DLL...

it's equals method if i use mqh (libraries)...but in DLL format

I use Visual Studio as well

Reason: