Download MetaTrader 5

Problem with execute other currency

To add comments, please log in or register
otai97
31
otai97  
Hello , i have problem with coding , when i attach EA on other currency , the EA not running , but when i closed previous currency , the lates currency will run by EA. How it could be? What must i put on my EA?
honest_knave
Moderator
2342
honest_knave  
Unfortunately nobody knows without seeing the code.
otai97
31
otai97  
extern double Lots = 0.01;
extern int Slippage   = 3;
extern double TP = 0.00200;
extern int MagicNumber=11111;
string text = "Forex Mudah";

int init()
{
   return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}

int start()
  {
  
  if(OrdersTotal() == 1){
  is_order_open() ;
}
   int ticket = 0;
      for (int i=OrdersTotal(); i < 1; i++)                        //Ñþäà ìû âòûêàå èíäèêàòîðà
         {
         //if((OrderType() == OP_SELL||OrderType() == OP_BUY) && OrderSymbol () ==Symbol())  
         //ticket++;
         
         ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Ask - 0.00200,text,MagicNumber,0,Green);
         ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Bid + 0.00200,text,MagicNumber,0,Green);
         
       }
  
   //if(ticket>0){
      //if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)){};
  //}
  
  

return(0);
}

bool is_order_open(){
   int OrderCnt,total=OrdersTotal();
   
   if(total == 2){
      //sell and buy both are open, wait until 1 is close
      return;
   }
   
   for(OrderCnt=0;OrderCnt<total;OrderCnt++)
   {
      OrderSelect(OrderCnt,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY) {
           //sell order close, and buy order is still open
           OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Ask - 0.00200,text,MagicNumber,0,Green);
      }
      
      if(OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) {
           //buy order close, and sell order is still open
           OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Bid + 0.00200,text,MagicNumber,0,Green);
      }
      
    }
  
  return false;
}


sorry , this is my code

whroeder1
17116
whroeder1  
otai97: when i attach EA on other currency ,
  if(OrdersTotal() == 1){
Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
To add comments, please log in or register