Download MetaTrader 5

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

To add comments, please log in or register
MetaQuotes Software Corp.
Moderator
184356
MetaQuotes Software Corp.  

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
Moderator
18023
Simon Gniadkowski  

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
1287
Sergey Sartakov  

"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
151
Do Hung  

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

 

Have you got next version yet?

Thanks! 

Sergey Sartakov
1287
Sergey Sartakov  
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...
Biliaminu Nurudeen
7
Biliaminu Nurudeen  
is good to be good god bless you
Sergey Sartakov
1287
Sergey Sartakov  
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...
okwh
1637
okwh  

Have you got next version yet?

Thanks!

Sergey Sartakov
1287
Sergey Sartakov  
DxdCn:

Have you got next version yet?

Thanks!


I need investments to continue the project...
Han Hui Tan
1006
Han Hui Tan  

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. 

Sergey Sartakov
1287
Sergey Sartakov  
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 

 



123
To add comments, please log in or register