Download MetaTrader 5
To add comments, please log in or register
Publish your article and thousands of people all over the world will read it!
MetaQuotes Software Corp.
MetaQuotes Software Corp. 2013.02.22 08:11 

New article MetaTrader 4 Expert Advisor exchanges information with the outside world has been published:

A simple, universal and reliable solution of information exchange between МetaТrader 4 Expert Advisor and the outside world. Suppliers and consumers of the information can be located on different computers, the connection is performed through the global IP addresses.

Author: Sergey Sartakov

Simon Gniadkowski
Simon Gniadkowski 2013.02.22 13:03  

Such effect is caused by the fact that practically any router performs the so called Network Address Translation (NAT). The network address is represented by the <protocol, IP, port> tuple. Any element of this tuple can be changed by router, it all depends on particular router model.


What you are actually talking about here is PAT  Port Address Translation. 

Sergey Sartakov
Sergey Sartakov 2013.03.08 21:49  

"Here is a software tool which provides MetaTrader 4 Expert Advisors with an ability of creating both server and clients. Clients can establish connections both with their own servers and with any other types of servers which provide peer-to-peer protocol connections."

Invalid translation - " peer-to-peer " !  Correct one is "point-to-point"

Do Hung
Do Hung 2013.03.09 02:40  

"In the next version of the article we will consider Peer-To-Peer (p2p) type of connection."


Have you got next version yet?


Sergey Sartakov
Sergey Sartakov 2013.03.09 12:45  

"In the next version of the article we will consider Peer-To-Peer (p2p) type of connection."


Have you got next version yet?


So far, my "hole punching"  can't manage with all routers. Idea is to reload totally all comunications work on intermediate server...something like in Skype. I'm working hardly on this...
Biliaminu Nurudeen
Biliaminu Nurudeen 2013.03.18 08:30  
is good to be good god bless you
Sergey Sartakov
Sergey Sartakov 2013.03.18 20:14  
is good to be good god bless you

It's only pity, to be good is not to be rich...Let God bless you as well...
okwh 2013.04.21 16:40  

Have you got next version yet?


Sergey Sartakov
Sergey Sartakov 2013.04.22 12:45  

Have you got next version yet?


I need investments to continue the project...
Han Hui Tan
Han Hui Tan 2015.02.21 17:48  

Dear Sergey Sartakov

I am trying to get your example(1.2.2. where the C++ program acts as an echo server, while expert advisor acts as a client for this C++ server) up running.

1. I have put the NetEventsProcDLL.dll in C:\Windows\System32 and also C:\Windows\SysWOW64 because I am using Window 7 64 bit. wihout putting the DLL at Syswow64 Folder, the echoserver.exe cant be run.

2. I have put the NetEventsProc.exe in "C:\NetEventsProc\" folder.

3.  The echoserver.exe is successfully run. I check using CMD command netstat -a. it shows my computer ip ( is listening at port 2000.


 4. At the metatrader 4, I have put the ImportNetEventsProcDLL.mqh in the Include file


5. I have changed the ps8_ServerIP  in the client.mq4 to which is my local computer IP. and compile successfully.


6. after I attach it to the  chart, and make sure the ALLOW Dll imports are checked as shown below.


7. After I run it, it still shows error as below. Please help


According to the  WINSOCK, WSAENETURNREACH (10051) means Network is unreachable.A socket operation was attempted to an unreachable network. This usually means the local software knows no route to reach the remote host.

But i have make sure my ip is set correctly as shown above.

please advise, dear experts here. 

Sergey Sartakov
Sergey Sartakov 2015.02.21 20:03  


Hi michaelt4268 !

The problem is  NetEventsProcDLL.dll functions are  designed to work with ANSI string but new MT4 works with UNICODE string.

For your separate example you should manage in such way:

For MT4 - correct:


#import "NetEventsProcDLL.dll"

// Only for Clients:

int ConnectTo(uchar&  ps8_ServerIP[], // in - string ps8_ServerIP = "0123456789123456"

              int     s32_Port,     // in 

              int&    ph_Client[]); // out - int ph_Client[1]






2. Before call to  ConnectTo(...)

   make conversion UNICODE string to ANSI string: 

    uchar uc_ServerIP[];

   StringToCharArray(ps8_ServerIP, uc_ServerIP);

   and now you can connect to server -  

    s32_Error = ConnectTo(uc_ServerIP, s32_Port, ph_Client);        

3.   NetEventsProcDLL.mgh

    correct this line -

   was -  string GetErrMsg(int ps32_Error)

   needed so -  string GetErrMsg(uint ps32_Error)


You example should work after that, but other examples should be corrected  this way too.

Besides include NetEventsProcDLL.dll functions defitnition c++ file must be corrected for another examples.





/ /123
To add comments, please log in or register