not getting ticket on ordersend()

 

is it possible to open an order without getting ticket back from the server?

if so what can i do without ticket?

 
redharel:

is it possible to open an order without getting ticket back from the server?

if so what can i do without ticket?


No not possible. Every trade you open gets from broker ticketnumber()
 
deVries:

No not possible. Every trade you open gets from broker ticketnumber()


i've seen some EA that uses sleep time to wait for the ticket back from server

if i'm gettting ticket why are they doing that?

 
redharel:


i've seen some EA that uses sleep time to wait for the ticket back from server

if i'm gettting ticket why are they doing that?


sourcecode ???
 
ticket = OrderSend(symbol_,ordertype_,lotsize_,price_,Slippage,stoploss_,takeprofit_,comment_,magic_,0,ordercolor_);
   if(ticket >= 0)
   {
      Sleep(2000);
                 
      if(OrderSelect(ticket,SELECT_BY_TICKET)) 
      {
    
        Print(Symbol()," Order ", OrderTypetoString(ordertype_)," for Symbol=", symbol_, " was executed Successfully. Ticket=",ticket);         
        return(ticket);
        
      }  
      else 
      { 
         Print(Symbol()," Order ", OrderTypetoString(ordertype_)," for Symbol=", symbol_, " was executed Successfully but cannot get ticket. Trying again...");
         Sleep(2000);
         if(OrderSelect(ticket,SELECT_BY_TICKET)) 
         {             
             Print(Symbol()," Got ticket for Order ", OrderTypetoString(ordertype_)," for Symbol=", symbol_, " Ticket=",ticket);
             return(ticket);
          } 
          else 
          {
             Print(Symbol()," Order ", OrderTypetoString(ordertype_)," for Symbol=", symbol_, " was executed Successfully but cannot get ticket. WILL NOT TRY AGAIN");  
             return(0);
          }
       }
     } 
     else 
     {
         errorcode_ = GetLastError();
         Print(Symbol()," ERROR - Couldn't execute order ", OrderTypetoString(ordertype_)," for Symbol=", symbol_," due to error ",errorcode_, " ",ErrorDescription(errorcode_)); 
         Alert(Symbol()," ERROR - Couldn't execute order ", OrderTypetoString(ordertype_)," for Symbol=", symbol_," due to error ",errorcode_, " ",ErrorDescription(errorcode_)); 
     }     
 
very strange coding why check
if(ticket >= 0)

ticket has to be > 0 if it succeed

if it is 0 then it has failed

 

0 is failed or -1?

 
redharel:

0 is failed or -1?


it is
int ticket;

for ordersend function isn't it code that way ??

int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)
The main function used to open a position or place a pending order.
Returns number of the ticket assigned to the order by the trade server or -1 if it fails. To get additional error information, one has to call the GetLastError() function.

So 0 we have not returned our answer back from broker
-1 answer is failing ordersend
>0 orderticketnumber()

 
redharel:

is it possible to open an order without getting ticket back from the server?

if so what can i do without ticket?

Yes it is! If you will get Error Code ERR_TRADE_TIMEOUT 128 you have no idea wither the send was successful or not.

The same problem occurs on ECN brokers, you must open first and then set stops. What do you do if the orderSend succeeds but the orderModify fails?

My approach is to log all errors and return ALWAYS. On the next tick the orderSelect loop will find it and modify the stops or if not it will retry.

 
WHRoeder:

Yes it is! If you will get Error Code ERR_TRADE_TIMEOUT 128 you have no idea wither the send was successful or not.

The same problem occurs on ECN brokers, you must open first and then set stops. What do you do if the orderSend succeeds but the orderModify fails?

My approach is to log all errors and return ALWAYS. On the next tick the orderSelect loop will find it and modify the stops or if not it will retry.



and if it's ECN broker and only ordersend() without the need of modifing the order?

 
redharel:


and if it's ECN broker and only ordersend() without the need of modifing the order?


Try out
Print("ticket =  ",ticket);
Reason: