Download MetaTrader 5

Orders comment checking by EA

To add comments, please log in or register
Hefajatur Rahman
345
Hefajatur Rahman  
i m facing problem in checking comment.
if (d = "A1"){ 
      
*** code here

 }

this condition not working... if comment is blank or anything, order is opening...i want new order open only when last detected order comment is A1.

extern double   lots=0.10;

int start()
  {
   
  datetime a;
  datetime max=0;
  datetime e;
  int b;
  string c;
  string d;
  string f;
  
  // select last opened order
  
  for(int i = (OrdersTotal()- 1); i >= 0; i --)
   {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      
      a = OrderOpenTime();
      if(a>max)
      {
      max=a;
      b = OrderTicket();
      c = OrderSymbol();   // select order defined symbol
      d = OrderComment();
      e = TimeCurrent();
      f = OrderType();
      }
      if (c != "XAUUSD"){
   if (d = "A1"){    
   if ((e-a)<30){
   int ThisBarTrade           =  0;
 if (Bars != ThisBarTrade ) {
   ThisBarTrade = Bars; 
  if (f == 0){
 if (c == "EURUSD" ){
       int ticket=OrderSend(c,OP_BUY,0.1,MarketInfo(c,MODE_ASK),3,0,0,"",0,0,Green);
       Sleep(30000);
 
   }
   if (c == "GBPUSD" ){
       int ticket1=OrderSend(c,OP_BUY,0.1,MarketInfo(c,MODE_ASK),3,0,0,"",0,0,Green);
       Sleep(30000);
 
   }
      
   }
  if (f == 1){
  if (c == "EURUSD" ){
   int ticket2=OrderSend(c,OP_SELL,0.1,MarketInfo(c,MODE_BID),3,0,0,"",0,0,Red);
    Sleep(30000);
   }
    if (c == "GBPUSD" ){
   int ticket3=OrderSend(c,OP_SELL,0.1,MarketInfo(c,MODE_BID),3,0,0,"",0,0,Red);
    Sleep(30000);
   }
   }
   }
   }  
   } 
   }
  }
     }

how can i open order if last order comment match only? any modification required?

Alain Verleyen
Moderator
31632
Alain Verleyen  
if (d == "A1"){
Hefajatur Rahman
345
Hefajatur Rahman  
thanks boss, i got it...
Hefajatur Rahman
345
Hefajatur Rahman  

i m in another trouble, suppose my signal provider open 5 orders in diff pair at a time or in 5 sec,

  my EA only select last opened order where others are missing  which opened 4 sec before....and sometimes EA opening 2 order of same pair where i only want one order as signal provider opened order with comments "A1"

my 2 EA attached where v1 is search last order only and open new one just copy of last detected order with specific lot size but its sometimes open order of  previous record order not latest one

in v2 , it first detect one order with specific comment then search again to match that comment of same its ticket, if not match open new order with its ticket in comment....but when opening new order in comment ticket number not coming  only 1 is printing in order comment that why its opening order again and again


i need some help, please

Files:
EA_00_v1.mq4 4 kb
EA_00_v2.mq4 3 kb
To add comments, please log in or register