0

I have tried but couldn't figure it out on my own.

I know MT4 provides Pipe and WebRequest(), as a means of communication, but WebSocket isn't built as part of the Programming. So for now, Pipe is the only thing available. But communication with Pipe breaks at some point. It skips some signals when sent.

How can I get around this please guys?

user3666197
  • 1
  • 6
  • 50
  • 92

3 Answers3

1

How can I get around this please guys ?

Free to use either a ZeroMQ or a nanomsg signalling / messaging framework

having been in such a need many years back, started to use ZeroMQ / MQL4-binding, so as to make MetaTrader Terminal work inside a QuantFX-analytics and ML-based augmented trading system.

No O/S localhost-only pipe, no file-based masquerades, but a fair, distributed, low-latency signalling/messaging, with:

  • remote keyboard / terminal system-console ( yes, added a DSL command language )
  • remote centralised logs ( avoids MQL4 execution get blocked from resource contentions )
  • distributed remote AI/ML-predictive engine, with latency under << 80 [ms] RTT
  • distributed remote automated trade-management processing

ZeroMQ is a way to go, if integration needs are to be kept under your own design controls. A brief sketch was presented here, in [ ZeroMQ hierarchy in less than a five seconds ] Section.

Feel free to read more posts on this and about the differences between WebSockets and ZeroMQ here, in the and other related posts.

user3666197
  • 1
  • 6
  • 50
  • 92
1

I tried ZeroMQ but couldn't get it working properly. I'm using WinSockets now and so far have no problems with it.

See: https://www.mql5.com/en/blogs/post/706665 Here you will find a way to use WinSockets in MQL as a server or as a client or both. I know links can become dead but there is no way to attach files to this answer and the code does not format properly so I cannot include it.

You can then use any programming language that also supports sockets to communicate with your MQL EA. I'm using the build-in node implementation. See: https://www.digitalocean.com/community/tutorials/how-to-develop-a-node-js-tcp-server-application-using-pm2-and-nginx-on-ubuntu-16-04

const net = require('net');
const port = 7070;
const host = '127.0.0.1';

const server = net.createServer();
server.listen(port, host, () => {
    console.log('TCP Server is running on port ' + port + '.');
});

let sockets = [];

server.on('connection', function(sock) {
    console.log('CONNECTED: ' + sock.remoteAddress + ':' + sock.remotePort);
    sockets.push(sock);

    sock.on('data', function(data) {
        console.log('DATA ' + sock.remoteAddress + ': ' + data);
        // Write the data back to all the connected, the client will receive it as data from the server
        sockets.forEach(function(sock, index, array) {
            sock.write(sock.remoteAddress + ':' + sock.remotePort + " said " + data + '\n');
        });
    });

    // Add a 'close' event handler to this instance of socket
    sock.on('close', function(data) {
        let index = sockets.findIndex(function(o) {
            return o.remoteAddress === sock.remoteAddress && o.remotePort === sock.remotePort;
        })
        if (index !== -1) sockets.splice(index, 1);
        console.log('CLOSED: ' + sock.remoteAddress + ' ' + sock.remotePort);
    });
});
Eric Dela Cruz
  • 1,503
  • 1
  • 15
  • 20
0

Pipe in MQL is implemented through files, so you can use files instead of pipes - you will receive same or faster result, and no need to care of the communication

Daniel Kniaz
  • 4,603
  • 2
  • 14
  • 20
  • Thanks for the response, but i notice when i use file i can't access files outside of mt4 folders. In fact when i try to access files in other folder outside it, i get errors. Or sometimes no errors and no results. –  May 24 '18 at 15:48
  • yes, it is not allowed to go outside the own file or Common folder (above the mt4 id folder). In order to solve that - you may use dll to read/write files outside the MT4 folder. – Daniel Kniaz May 24 '18 at 16:00