Examples: MetaTrader 4 Expert Advisor exchanges information with the outside world

 

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

 

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. 

 

"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"

 

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

 

Have you got next version yet?

Thanks! 

 
Dohung:

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

 

Have you got next version yet?

Thanks! 


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...
 
is good to be good god bless you
 
biliaminu:
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...
 

Have you got next version yet?

Thanks!

 
DxdCn:

Have you got next version yet?

Thanks!


I need investments to continue the project...
 

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 (192.168.1.6) 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 192.168.1.6 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. 

 
michaelt4268:

 

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:

1. 

#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]

...

...

...

#import 

      

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.

 

Regards

Sergey