Download MetaTrader 5
To add comments, please log in or register
How to earn at MQL5.community? Come and find out!
Rafael Rodriguez
49
Rafael Rodriguez 2014.10.19 21:52 

Hi all

I am trying to build a script that allows to send several pending orders (as a batch) for several pair but have not been able to find how to make it work.

This is what I have:

int start()
  { 
   RefreshRates();
   while( IsTradeContextBusy() ) { Sleep(100); }
//----
   int ticket=


OrderSend("EURUSD",OP_BUYLIMIT,0.03,1.2805,Slip,1.2725,1.3195,"1649",0,0,CLR_NONE);
OrderSend("USDJPY",OP_BUYLIMIT,0.03,102.76,Slip,101.76,104,"1649",0,0,CLR_NONE);
OrderSend("USDCAD",OP_BUYLIMIT,0.03,1.0823,Slip,1.0743,1.097,"1649",0,0,CLR_NONE);
OrderSend("GBPCHF",OP_BUYLIMIT,0.03,1.511,Slip,1.504,1.54,"1649",0,0,CLR_NONE);
OrderSend("EURJPY",OP_BUYLIMIT,0.03,138.2,Slip,138.9,136.6,"1631",0,0,CLR_NONE);
OrderSend("EURGBP",OP_BUYLIMIT,0.03,0.78,Slip,0.772,0.825,"1631",0,0,CLR_NONE);
OrderSend("EURNZD",OP_BUYLIMIT,0.03,1.54,Slip,1.531,1.595,"1631",0,0,CLR_NONE);
OrderSend("GBPAUD",OP_BUYLIMIT,0.03,1.835,Slip,1.845,1.817,"1603‏",0,0,CLR_NONE);
OrderSend("GBPNZD",OP_BUYLIMIT,0.03,1.936,Slip,1.926,1.998,"1579",0,0,CLR_NONE);
OrderSend("GBPCAD",OP_BUYLIMIT,0.03,1.855,Slip,1.871,1.812,"1570",0,0,CLR_NONE);
OrderSend("EURNZD",OP_BUYLIMIT,0.03,1.624,Slip,1.634,1.58,"1554",0,0,CLR_NONE);
OrderSend("GBPJPY",OP_BUYLIMIT,0.03,170,Slip,169.4,172.5,"1549",0,0,CLR_NONE);
OrderSend("CADJPY",OP_BUYLIMIT,0.03,92.4,Slip,91.7,93.92,"1540",0,0,CLR_NONE);
OrderSend("GBPNZD",OP_BUYLIMIT,0.03,1.912,Slip,1.902,1.965,"1531",0,0,CLR_NONE);

            Alert ("!open_batch_trade_executed");
   if(ticket<1)
     {
      int error=GetLastError();
      Print("Error = ",ErrorDescription(error));
      return;
     }
//----
   OrderPrint();
   return(0);
  }

The problem is that script doesn't work unless I attach it on same pair chart window as specified on OrderSend command.

Does anyone of you know how can I make this work independently of pair chart window where I drop script? (If it is possible on MQL4)

Thank you

Rafael

/
To add comments, please log in or register