How to get 2 EAs to 'talk' to each other on separate MT4 instances - page 2

 
EADeveloper:


better i dont know, this depends also on the developer i guess, in my opinion more easy, but i am use do develop in delphi also :-)

But this from the pipes:

if (SendPipeMessage(ServerName, Message, RetryForSeconds)) {
Print("Message succeeded (but may not have been processed by the server yet)");
} else {
Print("Message failed!");
}

normaly with the registry can not happen, because when client B is not availibel for the moment he can read later the value from registry and decide to use or not (i use for example in the registry a timestamp when i was writen, the pair, the timeframe and the command) so if the timestamp is to old, i delete the entry from the registry and do not fullfil the command.


Thanks EADeveloper.

One other idea - could I used MQ4 'Global Variables' ? Are global variables shared across MT4 client instances?

 
I would suggest to keep it simple by using the FileWrite & FileRead functions. For example you write 0 in case a position needs to stay open and 1 in case you want to close it.
 
VirtualReal:
I would suggest to keep it simple by using the FileWrite & FileRead functions. For example you write 0 in case a position needs to stay open and 1 in case you want to close it.


Thanks VirtualReal,

How do you think this would work in terms of performance?

I am inclined now to use this approach, especially now that I just realised that these functions are native to EA(I didnt realise this!)

 

VirtualReal,

I have not tested it yet, but I suspect the FileWrite & FileRead functions are limited to read/write files within each MT4 installation directory. This would prevent what I would like to do. Remember, I would like one EA (running on one MT4 instance) to send a 'close' signal to the other EA (running on the other MT4 instance). What do u think?

 
bgaughran:

VirtualReal,

I have not tested it yet, but I suspect the FileWrite & FileRead functions are limited to read/write files within each MT4 installation directory. This would prevent what I would like to do. Remember, I would like one EA (running on one MT4 instance) to send a 'close' signal to the other EA (running on the other MT4 instance). What do u think?


native read/write functions in MetaTrader can only access own "files" path inside the installation.

Like you sayd .. when you want to read/write across your harddisk, you NEED other solution ... Pipeline, Registry, Files (but in some dll, not native functions)

brgds

 

with this u can write to wherever u want c here

 
Thank-you every body for your very helpful feedback.

I need the fastest and most reliable way for 2 different EAs running on 2 different MT4 installations to communicate and send messages to each other.

I am aware now of the following possible ways:

1. file I/O

2. writing to registry


4. sockets / TCP IP

Speed & reliability are the most important requirements. What would you recommend? And do you know of any sample code I can use?
 
EADeveloper:


native read/write functions in MetaTrader can only access own "files" path inside the installation.

Like you sayd .. when you want to read/write across your harddisk, you NEED other solution ... Pipeline, Registry, Files (but in some dll, not native functions)

brgds


First of all, sorry for my late reply.

You're correct, the standard read/write functions only work inside the installation. Here you can find some flexible functions that can (haven't tried them myself) write outside the installation, https://www.forex-tsd.com/tools-utilities/386-mt4-files-functions-replacement.html

BTW, can you tell me why you want to run multiple instances? Is that because of multiple brokers?

HTH, Jim

 
bgaughran:


Thanks VirtualReal,

How do you think this would work in terms of performance?

I am inclined now to use this approach, especially now that I just realised that these functions are native to EA(I didnt realise this!)


Well, in case it's only a simple switch argument (i.e. to trade or not) the resulting CSV file is less than 1 kb so opening, reading or writing and closing it works in a split second.
 
VirtualReal:


First of all, sorry for my late reply.

You're correct, the standard read/write functions only work inside the installation. Here you can find some flexible functions that can (haven't tried them myself) write outside the installation, https://www.forex-tsd.com/tools-utilities/386-mt4-files-functions-replacement.html

BTW, can you tell me why you want to run multiple instances? Is that because of multiple brokers?

HTH, Jim


Hi VirtualReal,

I appreciate your response. Yes, I want to run multiple instances (on same PC) because I want to run an EA against multiple brokers. I need to send messages between each EA running on each instance.

The speed of execution is extremely important. The slower the execution, the greater the potential to lose cash.

My instinct is telling me, although as you quite rightly pointed out the file size is small, is that FILE I/O would be slower than options such as 'named pipes' or sockets. I don't mind using a more complex solution if it is quicker.

Do you have any experience with any - and maybe sample code?

THanks

Reason: