Problem using the OrderSelect function

 

Hi,

I have some trouble using the OrderSelect function:

int Ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,SSMA_Low,Ask+(SL*2)*Point,"Test",123456,0,Black);
  if(Ticket>0)
  {
   if(OrderSelect(Ticket, SELECT_BY_POS,MODE_TRADES)==true)
      Print("open price for the order ",OrderOpenPrice());
   else
      Print("OrderSelect returned the error of ",GetLastError());            
  }

This code always returns the following error:

OrderSelect returned the error of 0

Anyone has an idea on how I should write it ?

Best Regards,

Crak

 
Crak:

Hi,

I have some trouble using the OrderSelect function:

This code always returns the following error:

Anyone has an idea on how I should write it ?

Best Regards,

Crak


without testing I think you need to change this

if(OrderSelect(Ticket, SELECT_BY_POS,MODE_TRADES)==true) to this

if(OrderSelect(Ticket, SELECT_BY_TICKET,MODE_TRADES)==true)

 
The ==true is redundent if(true==true) is the same as if(true).,mode_trades is also redundant as it is the default.
 

You can use:

if(OrderSelect(Ticket, SELECT_BY_TICKET)==true)