Download MetaTrader 5

Libraries: Working with sockets in MQL5

To add comments, please log in or register
Automated-Trading
Admin
107756
Automated-Trading  

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  

hi, very good job!

The mql5.dll  work with EA  mq4?

 Have you example?

 

Andrey Voytenko
24992
Andrey Voytenko  
Look this example for MLQ4 - working with sockets without using DLL.
Robert Simon
44
Robert Simon  

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
442
Leny Boulard  

very nice work !

i will writing tool with now for testing this! 

sunshineh
1253
sunshineh  
Do you have also a dll with bidirectional socket conversation?!
JuergenBerger
12
JuergenBerger  

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
24992
Andrey Voytenko  
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  

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