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

 

Copying from mt4 -> mt5 and back using your method

works fine - only with mt5 -> mt4 there is a delay.

because there is no counter there. But in general it works fine.


And for W7 / Vista the terminal should be placed in the common folder MetaQuotes\Terminal\.

is a bit depressing. But there is a desire to write a simple program (not mql)

with a cycle of 1 sec - which would copy files from the folder

mt4 to mt5 and back if they are available. So as not to touch terminals

 
With win7 I myself got tired to put the script, here everyone writes that it has already been discussed and like everything is already clear how to put - but no way, I am not a programmer in MQ5 as "some" I am a LAMER, a dummy if you will. (I wrote without any back thoughts, and did not want to offend anyone). In short, all those who are in the tank like me: you need to set the rights on the folder public MT5 and there will be a folder Files, it is not visible but it is there))))), there we install a new terminal MT4. After installation the script in MT4 will stop generating an error and everything will be as it should be. To the author of the script thank you very much, nowadays few people want to share anything for nothing, everyone wants to fuck each other, pardon my expression, but you know how it is.
 
Thanks for the great stuff!!!
Very big request, add work only with orders with a certain magick number.
 
Im_hungry:

Copying from mt4 -> mt5 and back using your method

works fine - only with mt5 -> mt4 there is a delay.

because there is no counter there. But in general it works fine.


And for W7 / Vista the terminal should be placed in the common folder MetaQuotes\Terminal\.

is a bit depressing. But there is a desire to write a simple program (not mql)

with a cycle of 1 sec - which would copy files from the folder

mt4 to mt5 and back if they are available. So as not to touch terminals

Good afternoon.
From MT4 to MT5, how to realise it?
I understand mql on a rudimentary level.
Can you please post a ready solution?
I need MT5 to copy opening and closing of trades from MT4. I do not use stops.
thank you.
 

I get these warnings when compiling. Granted, they are just warnings and not errors. 

 Compiling 'Copyist_positions.mq4'... 
'cmd' - comparison expression expected C:\Program Files\MetaTrader 5\MQL5\Files\Metatrader 4\experts\scripts\Copyist_positions.mq4 (120, 46)
'cmd' - comparison expression expected C:\Program Files\MetaTrader 5\MQL5\Files\Metatrader 4\experts\scripts\Copyist_positions.mq4 (122, 46)
0 error(s), 2 warning(s) 

The above refers to these two lines of code:

//--- open price
double price_open(string symbol,int cmd) {if(cmd%2)return(bid(symbol));else return(nd(symbol,ask(symbol)));}
//--- close price
double price_close(string symbol,int cmd){if(cmd%2)return(ask(symbol));else return(nd(symbol,bid(symbol)));} 

I'm thinking that  "if(cmd%2)" should be changed to "if(cmd<2)" , but I'm not sure.

 

I get these errors when running the above script in MT4 

2013.02.26 06:16:38 Copyist_positions EURUSDm,H1: Error opening file 4103
2013.02.26 06:16:38 Copyist_positions EURUSDm,H1: ArrayInitialize function internal error

  

Here is the path I used to install Metatrader 4 and used to the run script:

C:\Program Files\MetaTrader 5\MQL5\Files\Metatrader 4\experts\scripts

 

It looks like a few people are having the same problems. Any help on how to fix the problems or a new clean version of the file would be appreciated. 

 


 

Documentation on MQL5: Array Functions / ArrayInitialize
  • www.mql5.com
Array Functions / ArrayInitialize - Documentation on MQL5
 
Jeysun:

I get these warnings when compiling. Granted, they are just warnings and not errors. 

 Compiling 'Copyist_positions.mq4'... 
'cmd' - comparison expression expected C:\Program Files\MetaTrader 5\MQL5\Files\Metatrader 4\experts\scripts\Copyist_positions.mq4 (120, 46)
'cmd' - comparison expression expected C:\Program Files\MetaTrader 5\MQL5\Files\Metatrader 4\experts\scripts\Copyist_positions.mq4 (122, 46)
0 error(s), 2 warning(s) 

The above refers to these two lines of code:

//--- open price
double price_open(string symbol,int cmd) {if(cmd%2)return(bid(symbol));else return(nd(symbol,ask(symbol)));}
//--- close price
double price_close(string symbol,int cmd){if(cmd%2)return(ask(symbol));else return(nd(symbol,bid(symbol)));} 

I'm thinking that  "if(cmd%2)" should be changed to "if(cmd<2)" , but I'm not sure.

I think the code is correct,  not very readable,  some might say horrible,  but correct.   I assume CMD is the order/operation type  OP_BUY is 0 OP_SELL is 1,  so OP_BUY%2 = 0  OP_SELL%2 = 1,   0 and 1 equate to false and true.  So  (cmd%2)  is true for a OP_SELL  and the open price for a OP_SELL is Bid  and close price is Ask
Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants
  • www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants - Documentation on MQL5
 
Jeysun:

  

Here is the path I used to install Metatrader 4 and used to the run script:

C:\Program Files\MetaTrader 5\MQL5\Files\Metatrader 4\experts\scripts

 

It looks like a few people are having the same problems. Any help on how to fix the problems or a new clean version of the file would be appreciated. 

Perhaps it is a UAC issue,  try installing in a folder other than Program Files,  for example C:\MT4Installs\  
 

RaptorUK:
Perhaps it is a UAC issue,  try installing in a folder other than Program Files,  for example C:\MT4Installs\  

 

Thanks for the explanation and suggestion.

Tried new installs of Metatrader 5 to "C:\MetaTrader 5 (2nd)\"  and Metatrader 4 to "C:\MetaTrader 5 (2nd)\MQL5\Files\MT4\", but still having the same errors when running the "copyist positions" script. My operating system is Windows 8.

I'm thinking it might what the "Translator positions" file is doing as it does not seem to write a file for "copyist positions" to read. I might have to break down a learn a little mql5 to understand it. It seems like the "copyist_positions" script would be better suited as an EA rather than a script. I have an MT4 to MT4 trade copier which works great. I'm having a hard time finding a MT5 to MT4 trade copier that works.

 
Thanks a lot for the code, came in handy.
 
Im_hungry:

But there was a desire to write a simple program (not mql)

with a cycle of 1 sec - which would copy files from the folder

mt4 to mt5 and back if they are available. So as not to touch terminals

I made a simple copier. We set from where, to where and copying 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.

Files:
CopyFile.zip  168 kb