Download MetaTrader 5

Libraries: Working with sockets in MQL5

To add comments, please log in or register
Automated-Trading
Admin
100921
Automated-Trading 2010.08.16 17:05 

Working with sockets in MQL5:

This library will allow you to tranfser realtime quotes from MetaTrader 5 to external server application.

The TCP protocol is used, it allows to transfer the data not only locally, but globally all over the Internet. The Winsock2 library (ws2_32.dll) is used for working with sockets. The direct calls of the library functions is impossible, because MQL5 doesnt allow to work with pointers and pass complex data structures as parameters of DLL functions. The library socket_mql5.dll, written in C++, is an intermediate wrapper, connecting the Expert Advisor and sockets library.

The interaction of MetaTrader 5 with external server application is presented at Fig:

Scheme of the interaction with MetaTrader 5 client terminal

The minimal set of the functions for one-way transfer (SocketOpen, SocketWrite, SocketClose) is implemented in socket_mql5.dll library.

An example of an Expert Advisor, connected to server and used to transfer the realtime tick data to external server application is included.

The archive contains:

  • An Expert Advisor
  • The socket_mql5.dll library (C++ source code is written in Visual Studio 2008)
  • The TCP server and TCP client (Delphi7 sources)

Author: Andrey Voytenko

Data transfer from MetaTrader 5 to server application

olivier
12
olivier 2010.09.06 16:02  

hi, very good job!

The mql5.dll  work with EA  mq4?

 Have you example?

 

Andrey Voytenko
23273
Andrey Voytenko 2010.10.25 22:40  
Look this example for MLQ4 - working with sockets without using DLL.
Robert Simon
44
Robert Simon 2011.07.01 22:39  

Thanks for this!

but for x64 version u must change my_rand() rutins

//--------------------------------------------------------------------------//
unsigned long long rand64()
//--------------------------------------------------------------------------//
{
        return ( static_cast<unsigned long long>( rand() ) << 32 ) | rand();
}

something like this.




Leny Boulard
422
Leny Boulard 2013.03.11 14:05  

very nice work !

i will writing tool with now for testing this! 

sunshineh
1241
sunshineh 2014.02.15 00:04  
Do you have also a dll with bidirectional socket conversation?!
JuergenBerger
12
JuergenBerger 2014.07.03 19:03  

The solution work very fine on MT5 32bit.

I have tried to compile the socket_mql5.dll for 64 bit but it do not work. Can someone give me a socket_mql5.dll 64 bit which is OK.

 

Thank you

Jürgen Berger 

Andrey Voytenko
23273
Andrey Voytenko 2014.07.29 09:31  
JuergenBerger:

I have tried to compile the socket_mql5.dll for 64 bit but it do not work. Can someone give me a socket_mql5.dll 64 bit which is OK.

Now the project has been updated and is available for 64-bit version. Please test.
carmensilvia
16
carmensilvia 2016.04.26 00:22  

how can i implement a "recv" function on this project?

...and receive data inside of mql5 for execute others functions? 

To add comments, please log in or register