Download MetaTrader 5

Major OrderSelect() bug! Seen on backtester and demo - might be on live too

To add comments, please log in or register
Bogdan Alin Baltatu
2927
Bogdan Alin Baltatu  

This has surfaced while working these days. It seems that, regardless that an order is active or closed (we tried only with market orders), both modes OrderSelect(), MODE_TRADES and MODE_HISTORY, will return true. If an order never existed, both will return correctly, false. Test it yourself: launch a market order and try the following script:

 

void OnStart()
  {
   int ticket=41341306;// Your test Ticket!!!!!
   if (OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)==true)
     Print("MODE_TRADES: ticket ",ticket," is SELECTED");
   else
     Print("MODE_TRADES: ticket ",ticket," is NOT SELECTED");
     
   if (OrderSelect(ticket,SELECT_BY_TICKET,MODE_HISTORY)==true)
     Print("MODE_HISTORY: ticket ",ticket," is SELECTED");
   else
     Print("MODE_HISTORY: ticket ",ticket," is NOT SELECTED") ;
  }
whroeder1
14779
whroeder1  
Read the documentation OrderSelect - MQL4 Documentation

Note

The pool parameter is ignored if the order is selected by the ticket number. The ticket number is a unique order identifier.

Bogdan Alin Baltatu
2927
Bogdan Alin Baltatu  

Thanks 

To add comments, please log in or register