Trade copier project help

 

Hi everyone,

For training and educational purposes, I am working on a trade copier project.

The project consists of two EAs (Master and Slave) which communicate through a mysql database.

I am able to write, read into the database but I have the following issue :

How should I organize the information flow ? Let me clarify that :

1) I place a trade on the master account
2) The master EA sends out the information about the trade
3) The slave EA reads the information
4) A trade is placed on the slave account

What happens when I modify a trade o close a trade on the master account ? How can I send the information to the slave account so it understands it's not a new trade ?

What will be the easiest flow between the two accounts and using a database ?

Thanks for your inputs.

Once I have a first working version of the project - I will release it on the forum but my code is still too messy for the moment.

Cheers

 

if u r a u.s. citizen & u have an acc. in the u.s.a. there in no problem at all because hedging is not allowed so if u buy 1 lot EURUSD then u sell 1 lot EURUSD the buy order simply closed

 
qjol:
if u r a u.s. citizen there in no problem at all because hedging is not allowed


I am not a us citizen.

Thanks for the reply

 
u can use magic no.
 

Hi,

I am trying to check if the order is already in the db first and if not, to add it. I have this until now:


int start()
  {
   
  for(int iCompteur = 0; iCompteur <= OrdersTotal() - 1; iCompteur++)
    {
    OrderSelect(iCompteur, SELECT_BY_POS);
    string query = "";
    int length = 0;      
    query = StringConcatenate("SELECT * from orders where ticket =", "\"", OrderTicket(), "\"", ";");
    length = StringLen(query);
    mysql_real_query(mysql, query, length);
    int myerr = mysql_errno(mysql);
    if(myerr > 0)    
      {
      query = StringConcatenate("insert into orders(ticket) values(",OrderTicket(), ");");
      length = StringLen(query);
      mysql_real_query(mysql, query, length);
      myerr = mysql_errno(mysql);
      if(myerr > 0)
        Print("error=",myerr);
      }
    }     

Unfortunately, When I am trying to execute the EA, I got the following error message:

2011.11.10 20:44:15 Orders EURUSD,H1: error=2014

I tried to add a mysql_free_result(myerr); before the second query but when I do that, I get a critical error and the expert just stop.

Thanks for your help.

Cheers

 

I would suggest you to work with HTML GET/POST instead of trying to connect directly against Mysql DB. Why?. Because the link between mysql and mt4 is a pain in the..

you could rather develop two simplest php insert/read files for you to write and read the data base, nevertheless, it also keep your environment safe from any hacker.

Furthermore, i would suggest you to create a type of communication protocol, in order to standardize the chat between master and slave. You could take advantages of variables such as magic number and/or computers IP address etc.