Discussion of article "How to Copy Trading from MetaTrader 5 to MetaTrader 4" - page 13

 
zhserg:

I made a simple copier. Set from where, to where and copy interval.

exe file in the archive
 
Warstein:
Thanks for the great stuff!!!
Very big request, add work only with orders with a certain magik number.

I support the idea, maybe someone will write, and so the code is great thanks to the author everything is super! I just need to find a good trader and ask invest ;)

 

We should add.

1. Lot proportionality - from 5 digits to 4 digits - the lot moves by 1 digit too.

In general, it is better to pull not the lot, but the free margin and lot and dights, and at the receiver recalculate the lot in accordance with the available free margin and quote decimal places.

This way mani-management will be preserved - without it the program loses its meaning.

2. Prefixes-suffixes to symbols - sometimes DC calls a trading symbol not EURUSD, but EURUSD_byaka (it is probably better to make the correspondence "from which to which" symbol duplicated in a separate configuration file).

3. it would be nice to realise copying of a file to several mt4 files.

For example by receiving mt4 file from mt5 folder with the help of:

#import "kernel32.dll"
   bool CopyFileA(string lpExistingFileName, string lpNewFileName, bool bFailIfExists);
#import

/////////////////

CopyFileA(TerminalPath()+CharToStr(92)+"experts"+CharToStr(92)+"files"+CharToStr(92)+fSymbol+".txt",CopyTo1+fSymbol+".txt",false);

This way you can go beyond the mt4 file sandbox.

In mql5, unfortunately, this and similar MSDN tricks do not work.

In general, I will try it out, and if there are no bugs, I won't write my own for now. Thanks.

 
zhserg:

I made a simple copier. Set from where, to where and copy interval.

Start copying with the "Save/start" button. During the work it will blink ))).

In Translator positions.MQ5 you can change the line int han=FileOpen(subfolder+"\\\experts\\\files\\\"+folder+".csv",FILE_WRITE|FILE_SHARE_READ|FILE_ANSI,","); to int han=FileOpen(folder+".csv",FILE_WRITE|FILE_SHARE_READ|FILE_ANSI,","); i.e. the file will be written to the \\Program Files\MetaTrader 5\MQL5\Files folder.

You can use a bootnik. It will be both over the network and inside the computer.

@Echo off
:loop
xcopy "F:\folder\*.txt" "\\Comp1\folder" /Y /R /C /I /G /Z /D >nul
xcopy "C:\Program Files\MetaTrader 5\MQL5\Files\Translator positions.csv" "C:\Program Files\MetaTrader 4\experts\files" /Y /R /C /I /G /Z /D >nul
timeout /t 1
goto :loop

By the way, for mega file synchronisation I recommend Microsoft SyncToy 2 .1 http://www.microsoft.com/en-us/download/details.aspx?id=15155.

SyncToy 2.1
SyncToy 2.1
  • www.microsoft.com
Note: There are multiple files available for this download. Once you click on the “Download” button, you will be prompted to select the files you need. Overview There are files from all kinds of sources that we want to store and manage. Files are created by our digital cameras, e-mail, cell phones, portable media players...
 
All this is no longer relevant, the article has outlived itself, a new compiler mql4++ with advanced features will be released soon, everything will change.
 

I think the problem is to do with where Metatrader stores the data. In the most recent versions of Windows it does not use subfolders of the installation folder.

On server 2008 (in my case) MT5 uses:
C:\Users\[username]\AppData\Roaming\MetaQuotes\Terminal\[long hex number]\MQL5\etc...

Each terminal installation uses it's own folder in this location with a unique [long hex number].  I tried installing MT4 in the above folder path but it also reads and writes from it's own unique data folder so that doesn't work either.  In any case, executing programs from this location is probably not a good idea.

I suspect this is the issue on Windows 8 as well.

I'm stuck for ideas at this point, but hope this information is useful.

 

My MT4 data file locations on Windows Server 2008:

C:\Users\[username]\AppData\Local\VirtualStore\Program Files\[name of MT4 program folder]

I'm guessing that the OS is redirecting file operations.

 

4103 - error opening file, means that MT5 is writing trades to some file, and MT4 can't 'find' it.

This is happening because MT5 functions differently from MT4. In MT5 the folder where we install, is different from which it is run. For example, I installed MT5 in C:\Accounts\MT5, and MT4 in C:\Accounts\MT5\MQL\Files\MetaTrader 4.

MT5 created a folder C:\Users\[username]\AppData\Roaming\MetaQuotes\Terminal\[long hex number]\MQL5\etc... and actually runs from here. So MT5 is writing the trades somewhere in this folder.

As by the original article, MT4 should be 'inside' the MT5 folder. So the solution lies in making the MT5 install folder "SAME" as the run folder. And the simplest way is:

1. uninstall all MT5 instances

2. Delete the folder 'Metaquotes' from C:\Users\[username]\AppData\Roaming\

Now we will make install folder same as run folder: 

3. Reinstall MT5. It should not be in Program files folder, make it for example C:\Accounts\MT5. While installing, uncheck 'launch after finish' (critical step)

4. BEFORE running MT5 for the first time, right click MT5 shortcut on the desktop, click properties, add "/portable" to the path, without quotes. So it will be C:\Accounts\MT5\terminal.exe /portable. (Note that there is a space after terminal.exe, forward slash, portable without any capital letter). Click OK.

Now we will install MT4, copy EAs, and run terminals

5. Install MT4 in C:\Accounts\MT5\MQL\Files\MetaTrader 4. (Note that the folder name MetaTrader 4, or whatever it is, should be identical to the name in EAs)

6. Copy Translator and Copyist EA in respective folders.

7. Run both MT5 master and MT4 slave.

8. Enjoy !!! 

Tip: Do not proceed to next step, if something is not done properly. 

Sorry for using 'non technical' language, this is maximum what you can expect from a doctor!

 
doctornasir:

4103 - error opening file, means that MT5 is writing trades to some file, and MT4 can't 'find' it.

This is happening because MT5 functions differently from MT4. In MT5 the folder where we install, is different from which it is run. For example, I installed MT5 in C:\Accounts\MT5, and MT4 in C:\Accounts\MT5\MQL\Files\MetaTrader 4.

MT5 created a folder C:\Users\[username]\AppData\Roaming\MetaQuotes\Terminal\[long hex number]\MQL5\etc... and actually runs from here. So MT5 is writing the trades somewhere in this folder.

As by the original article, MT4 should be 'inside' the MT5 folder. So the solution lies in making the MT5 install folder "SAME" as the run folder. And the simplest way is:

1. uninstall all MT5 instances

2. Delete the folder 'Metaquotes' from C:\Users\[username]\AppData\Roaming\

Now we will make install folder same as run folder: 

3. Reinstall MT5. It should not be in Program files folder, make it for example C:\Accounts\MT5. While installing, uncheck 'launch after finish' (critical step)

4. BEFORE running MT5 for the first time, right click MT5 shortcut on the desktop, click properties, add "/portable" to the path, without quotes. So it will be C:\Accounts\MT5\terminal.exe /portable. (Note that there is a space after terminal.exe, forward slash, portable without any capital letter). Click OK.

Now we will install MT4, copy EAs, and run terminals

5. Install MT4 in C:\Accounts\MT5\MQL\Files\MetaTrader 4. (Note that the folder name MetaTrader 4, or whatever it is, should be identical to the name in EAs)

6. Copy Translator and Copyist EA in respective folders.

7. Run both MT5 master and MT4 slave.

8. Enjoy !!! 

Tip: Do not proceed to next step, if something is not done properly. 

Sorry for using 'non technical' language, this is maximum what you can expect from a doctor!

Thanks for taking the time to write that.

Another way is to keep the default installation settings and make the connection between the two folders with a symbolic link.

http://en.wikipedia.org/wiki/NTFS_symbolic_link

 

mql4++ compiler

is this a new version for the receiver in mt4, with additional parameters?