Multiple mt4 broker communication?

 

Hello everyone,

I have scoured the internet trying to figure out how to make multiple (separate broker) mt4 platforms read and write to a universal shared file. This shared file would not reside within the mt4 platform framework, but be an external application. I would like this file to receive real time data, from multiple broker terminals, as well as have the ability to be read from multiple terminals.

I've looked into dlls, which I assume must be used. Is anyone willing to provide input, or work on such a project?

I would love some serious response.

Thank You,

-wolfe

 

Oh my god, I was just about to post a question regarding the exact same thing

I thought I read somewhere about MT4 EA's being able to read/write history logs or whatever, to/from TXT files.

What I'm looking for is to have ONE platform write to a TXT file when it's time to place a trade for example, while the SECOND platform is reading that TXT file and when it sees that the signal from the ONE platform has written to that TXT file then the SECOND platform makes the trade.

Hope to get an answer soon.

 
matrixebiz:
Oh my god, I was just about to post a question regarding the exact same thing

I thought I read somewhere about MT4 EA's being able to read/write history logs or whatever, to/from TXT files.

What I'm looking for is to have ONE platform write to a TXT file when it's time to place a trade for example, while the SECOND platform is reading that TXT file and when it sees that the signal from the ONE platform has written to that TXT file then the SECOND platform makes the trade.

Hope to get an answer soon.

This is basically what I would like to do. Have multiple EA's on seperate brokers, reading from, and writing to a universal text file. I'm sure it can be done, I'm just not quite sure how to go about it. The problem is, the text file can't be in the mt4 directory, because we are using more than one broker platform to "communicate" with a "shared" file.

Thanks for the interest matrixebiz!

 

I posted in a thread here;

http://www.forexfactory.com/showthread.php?t=103881

to see if it is possible now for the newer versions of MT4 to write/read to txt files outside it's own directory which wasn't possible before.

 

There are commands like FILE_WRITE but not sure if you can change the name of the file to a directory +filename.

int FileWrite( int handle, ...)

The function is intended for writing of data into a CSV file, delimiter being inserted automatically. After writing into the file, the line end character "\r\n" will be added. Numbers will be converted into a text at output (see the Print() function).

Returns the count of written characters or a negative number if an error occurs.

To get the detailed error information, one has to call the GetLastError() function.

Parameters:

handle - File handle returned by the FileOpen() function.

... - User data to write, separated by commas. It can be up to 63 parameters.

Data of int and double types are automatically converted into a string, but those of color, datetime and bool typesare not automatically converted and will be written to file as they are (as integers).

Arrays cannot be passed as a parameter, they can be output elementwise.

Sample:

int handle;

datetime orderOpen=OrderOpenTime();

handle=FileOpen("filename", FILE_CSV|FILE_WRITE, ';');

if(handle>0)

{

FileWrite(handle, Close[0], Open[0], High[0], Low[0], TimeToStr(orderOpen));

FileClose(handle);

}

Change "filename" to "C:\Temp\filename" ??

Then you can do a FileReadString;

string FileReadString( int handle, int length=0)

The function reads the string from the current file position. Applies to both CSV and binary files. For text files, the string will be read before the delimiter. For binary file, the given count of characters will be read to the string. To get the detailed error information, one has to call the GetLastError() function.

Parameters:

handle - File handle returned by the FileOpen() function.

length - Amount of characters for reading.

Sample:

int handle;

string str;

handle=FileOpen("filename.csv", FILE_CSV|FILE_READ);

if(handle>0)

{

str=FileReadString(handle);

FileClose(handle);

}

Maybe we'll get an answer soon

 

if you already know how to actually get an EA to write a file in MT4 then you can create a simple looping DOS batch file to copy the file from one location to another. If that helps.

:loop

xcopy c:\temp\test.csv c:\temp2

del c:\temp\test.csv

goto:loop

so the batch file will just keep checking the folder and once the file is created it will copy it from the temp directory to the temp2 directory or whatever.

 

Ah, Ha, got this from another user post;

"I finally worked out how to read a file from another folder in mq4 took me ages

you have to enable dlls in the ea ( not sript) and do it this

string buffer=ReadFile("C:\\Program Files\\MetaTrader - North Finance\\experts\\files\\Signal.txt ");

siggy=StringSubstr(buffer,0,1);

if (siggy=="1") siggy="BUY";

if (siggy=="2") siggy="STRONG BUY";

if (siggy=="3") siggy="SELL";

if (siggy=="4") siggy="STRONG SELL";

and you need to use this at the front of the ea

#define OF_READ 0

#define OF_WRITE 1

#define OF_READWRITE 2

#define OF_SHARE_COMPAT 3

#define OF_SHARE_DENY_NONE 4

#define OF_SHARE_DENY_READ 5

#define OF_SHARE_DENY_WRITE 6

#define OF_SHARE_EXCLUSIVE 7

#import "kernel32.dll"

int _lopen (string path, int of);

int _lcreat (string path, int attrib);

int _llseek (int handle, int offset, int origin);

int _lread (int handle, string buffer, int bytes);

int _lwrite (int handle, string buffer, int bytes);

int _lclose (int handle);

#import "

 

Interesting matrixebiz,

Not sure I fully understand yet, but I will give it a try.

I've been trying to import a dll created in VB that is installed outside of the mt4 terminal, but I keep getting:

2008.09.27 16:51:46 DLLSample EURUSD,M1: initialized

2008.09.27 16:51:46 DLLSample EURUSD,M1: expert stopped

2008.09.27 16:51:46 DLLSample EURUSD,M1: cannot load library 'C:\WINDOWS\system32' ( 250 characters)" class="linkator">error 126)

I can't figure out how to take care of error 126, or even what it is. This is very frustrating!

 

Going to try this example:

Create your own MetaTrader extension (dll) - Part 1 | www.metatrader.info

Article by a great contributer of the forum. CodersGuru.

 

Still not having much luck!

An example of what I need a dll to do:

I want an EA on IBFX server to be able to tell me the bid price of EUR/USD on FXDD server.

Shouldn't be impossible, but can't figure it out yet!

Any ideas?

 

This is a re-occurring error I keep having:

2008.09.28 20:58:01 DLLSample EURUSD,M1: cannot call function 'StorePrice_EURUSD' from dll 'C:\WINDOWS\system32\demosp.dll' (error 127)

Does anyone know how to solve the error 127?

Reason: