A DLL-free solution to communicate between MetaTrader 4 terminals using Named Pipes

 
Prompted by the new article at https://www.mql5.com/en/forum/127024, the attached files are an example of sending messages asynchronously between different instances of MT4 on the same computer, using named pipes.

Inspired by the MT5 article, but there are some major differences in the methodologies used. Broadly speaking, the method used here is much lower-volume, but non-stateful: it does not assume a continuous unbroken connection between sender and receiver, and it does not use blocking calls which require an infinite loop in start().

See the readme.txt file for instructions on how to set up the demo.

N.B. None of this is guaranteed - or even likely - to be bug-free. It's a quick riposte to the increasing littering of the MT4 forum with MT5 articles.

Files:
 
jjc:
Prompted by the new article at https://www.mql5.com/en/forum/127024 [...]

Oh, BTW, this is "DLL-free" in the same largely meaningless sense as the MT5 code. There are no custom DLLs, but it still uses API calls and therefore requires "Allow DLL imports" to be turned on.
 
Thanks Jjc.
 
jjc:
Prompted by the new article at https://www.mql5.com/en/forum/127024, the attached files are an example of sending messages asynchronously between different instances of MT4 on the same computer, using named pipes.

Inspired by the MT5 article, but there are some major differences in the methodologies used. Broadly speaking, the method used here is much lower-volume, but non-stateful: it does not assume a continuous unbroken connection between sender and receiver, and it does not use blocking calls which require an infinite loop in start().

See the readme.txt file for instructions on how to set up the demo.

N.B. None of this is guaranteed - or even likely - to be bug-free. It's a quick riposte to the increasing littering of the MT4 forum with MT5 articles.


Excellent, say can you expand the mqh includes to pass integers and float values too???? That would be greatly appreciated!!

tradingbigboy

 
tradingbigboy:

Excellent, say can you expand the mqh includes to pass integers and float values too???? That would be greatly appreciated!!

Wow, three months on, an expression of interest in this...

It's simplest to pass numeric data simply by casting it to a string and then back again. For example, the sending code uses something DoubleToStr() to convert the number to a string for transmission with SendPipeMessage(). The receiving code then uses StrToDouble() or StrToInteger() to convert the data back again. Not a highly efficient way of passing numeric data, but that shouldn't matter in the context of the local machine.

 
jjc:

Wow, three months on, an expression of interest in this...

It's simplest to pass numeric data simply by casting it to a string and then back again. For example, the sending code uses something DoubleToStr() to convert the number to a string for transmission with SendPipeMessage(). The receiving code then uses StrToDouble() or StrToInteger() to convert the data back again. Not a highly efficient way of passing numeric data, but that shouldn't matter in the context of the local machine.


thanks!!

tradingbigboy

Files:
 
tradingbigboy:


thanks!!

tradingbigboy


One more question, if I want just the latest message from the pipe server is that going to be in array position 0??

TBB

 
tradingbigboy:

One more question, if I want just the latest message from the pipe server is that going to be in array position 0??

The order of messages within the array is not guaranteed. If you care about the order, then one option is to get the senders to include a timestamp in their message. The receiver then parses these timestamps out of the messages, and processes them in order.
 

I realize this is a super old post, but I'm just getting into this sort of thing.

I downloaded the files, and am having fun playing with them.

I changed the message from Hello! to Bid... and I created a Comment that displays the Bid on the Chart.

Having done that, I have to say, watching the sending broker's platform and the reciever's platform, I notice a delay in when the data gets to the reciever. Do you know of a way to speed this up?

Also, I notice there are times when the Comment displays 0.00000... why would that be?

Any ideas would be helpful to this newbie.... Thanks

jjc:
Prompted by the new article at https://www.mql5.com/en/forum/127024, the attached files are an example of sending messages asynchronously between different instances of MT4 on the same computer, using named pipes.

Inspired by the MT5 article, but there are some major differences in the methodologies used. Broadly speaking, the method used here is much lower-volume, but non-stateful: it does not assume a continuous unbroken connection between sender and receiver, and it does not use blocking calls which require an infinite loop in start().

See the readme.txt file for instructions on how to set up the demo.

N.B. None of this is guaranteed - or even likely - to be bug-free. It's a quick riposte to the increasing littering of the MT4 forum with MT5 articles.

 

I am working with the named pipe files that I down loaded from this post.

Can you tell me how to send more data points at the same time? Right now all it sends is "Hello".... which I have changed to Bid. But I would like to include more data... maybe Ask, time, spread, etc...

Thanks for your help.

jjc:
Prompted by the new article at https://www.mql5.com/en/forum/127024, the attached files are an example of sending messages asynchronously between different instances of MT4 on the same computer, using named pipes.

Inspired by the MT5 article, but there are some major differences in the methodologies used. Broadly speaking, the method used here is much lower-volume, but non-stateful: it does not assume a continuous unbroken connection between sender and receiver, and it does not use blocking calls which require an infinite loop in start().

See the readme.txt file for instructions on how to set up the demo.

N.B. None of this is guaranteed - or even likely - to be bug-free. It's a quick riposte to the increasing littering of the MT4 forum with MT5 articles.

 
mrchuckw:

I am working with the named pipe files that I down loaded from this post. [...]

I only wrote this post and code as a quick expression of annoyance at the fact that the MT4 forum was being littered with articles for MT5.

It's a useful exercise and demonstrates some useful techniques. But, for real-life use, named pipes wouldn't be top of my list of ways of communicating between MT4/5. I'd use something like <link removed by moderator> instead.
Reason: