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

 

New article How to Copy Trading from MetaTrader 5 to MetaTrader 4 is published:

Is it possible to trade on a real MetaTrader 5 account today? How to organize such trading? The article contains the theory of these questions and the working codes used for copying trades from the MetaTrader 5 terminal to MetaTrader 4. The article will be useful both for the developers of Expert Advisors and for practicing traders.

Author: Николай

 
Useful, If it works for me at demo I am going to try this on real account.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Account Properties - Documentation on MQL5
 

Very very useful work to use my MT5's EA with brokers that still use MT4 platform, thanks a lot !

Unfortunaltely I got some unexpected errors on MT4 side by using it (Terminal - Experts  windows) : "Copyist_positions EURUSD,M1: ArrayInitialize function internal error" 

And some  warnings when compiling source code on MT4 MetaEditor :" 'cmd' - comparison expression expected C:\Program Files\MetaTrader 5\MQL5\Files\MetaTrader 4\experts\Copyist_positions.mq4 (127, 46)"

Some idea to fix this bugs ? 


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

Very very useful work to use my MT5's EA with brokers that still use MT4 platform, thanks a lot !

Unfortunaltely I got some unexpected errors on MT4 side by using it (Terminal - Experts  windows) : "Copyist_positions EURUSD,M1: ArrayInitialize function internal error" 

And some  warnings when compiling source code on MT4 MetaEditor :" 'cmd' - comparison expression expected C:\Program Files\MetaTrader 5\MQL5\Files\MetaTrader 4\experts\Copyist_positions.mq4 (127, 46)"

Some idea to fix this bugs ? 

Thank you, we will check it.

Try the codes from the original russian article.

 
Automated-Trading:

Thank you, we will check it.

Try the codes from the original russian article.

Bug is fixed now, I have just reinstalled MT5 & MT4 and it works !

Thanks a lot for your work. 

 

I might be the unlucky one that that error message still continuously prompt out even I reinstalled MT5 and MT4 for both source codes in English and Russian.  Could any one help on this?  I actually need this function urgently.  Many thanks!

 P.S.  I've already tried to debug this by placing "Translator positions.csv" in every file level but still the file cannot be found with the code 4103.  The only difference between my path and this article is just the drive (mine is E:\).  I did try to put the same csv file in the newly created path in C:\ but same error prompted.  Thus, the  file seemed to be transparent to the copyist program.  :(

 
hftsang:


 P.S.  I've already tried to debug this by placing "Translator positions.csv" in every file level but still the file cannot be found with the code 4103.  The only difference between my path and this article is just the drive (mine is E:\).  I did try to put the same csv file in the newly created path in C:\ but same error prompted.  Thus, the  file seemed to be transparent to the copyist program.  :(

This error 4103 is about chart operations. Don't you confuse something?

Charts

 

 

ERR_CHART_WRONG_ID

4101

Wrong chart ID

ERR_CHART_NO_REPLY

4102

Chart does not respond

ERR_CHART_NOT_FOUND

4103

Chart not found

Documentation on MQL5: Chart Operations / ChartID
  • www.mql5.com
Chart Operations / ChartID - Documentation on MQL5
 

I did think that I have been a bit confused since from others' program coding about fileopen function, they do check the error 4103 like the following:

int start()
{
int Handle, nbre=0;//, sens=2, ticket=3333;
string File_Name="trading.txt", sens=2, ticket=3333;
//-----Lecture-------------------------------------------------------+
Handle=FileOpen(File_Name,FILE_CSV|FILE_READ,";");// File opening
if(Handle<0) // File opening fails
{
if(GetLastError()==4103) // If the file does not exist,..
Alert("No file named ",File_Name);//.. inform trader
else // If any other error occurs..
Alert("Error while opening file ",File_Name);//..this message
PlaySound("Bzrrr.wav"); // Sound accompaniment

return; // Exit start()

Actually, I compiled the source https://c.mql5.com/2/8/copyist_positions.mq4 successfully with some debug displays added and this program was run as a script.  The following error occurred in the Experts window:

22:02:25 Copyist_positions EURUSD,M1: Error opening file 4103,Translator positionsHandle=-1

22:02:30 Copyist_positions EURUSD,M1: Error opening file 4103,Translator positionsHandle=-1

22:02:30 Copyist_positions EURUSD,M1: ArrayInitialize function internal error

The integer handle is clearly not equal to zero and fileopen function failed (though 4103 may not be the exact error code referring to this error since it's just got from getlasterror()?).

 

Much appreciated for any feedback for the above. 

 

Hi,

would it be possible to rewrite the master part from MQ5 to MQ4? To be both usable on MT4 platform? Any idea how to convert, please?


Thanks a lot


 

this tools have a problem/bug that will open position until MT4 position up to MT5 lots,

that means it neglect the extern double  koeff_lot=1.0;( position volume coefficient ) in MT4 scripts

if I set the koeff_lot to 0.1

If MT5  open 2 lot ,surely i want MT4 open 0.2 lot only

but this tools will enter 0.2 + 0.2 +0.2 , until MT4 open 2 lots

, it's terrible~ ~

 

can anyone fix this problem? 

 

 

someone tell me to fix it,

add :

if ( (MT4_lots_total_in_that_symbol()  >= MT5_lots() )  return(0);

 

I know how to code  MT4_lots_total_in_that_symbol() ,

but hows to code  MT5_lots() ?

I know zero in MQL5, and don't know how to pass this value to Script in MT4 Client Terminal ? 

Thanks 

Reason: