OrderSelect, pool MODE_HISTORY, test and questions

To add comments, please log in or register
Davide Tedesco
183
Davide Tedesco  

Hi at all,


can i use this ---> OrderSelect([int ticket], SELECT_BY_TICKET, MODE_HISTORY)   ?


In the execution this method run, but the return is unexpected for me.


USE CASE:

i have open a buy order, ticket of this order = 97936536

run my EA, and test it (order ticket 97936536. it still open):

OrderSelect(97936536, SELECT_BY_TICKET, MODE_TRADES)   ----> return TRUE (right);

OrderSelect(97936536, SELECT_BY_TICKET, MODE_HISTORY)   ----> return TRUE (what ???);


thanks at all

Keith Watford
Moderator
20585
Keith Watford  
Davide Tedesco:

OrderSelect(97936536, SELECT_BY_TICKET, MODE_TRADES)   ----> return TRUE (right);

OrderSelect(97936536, SELECT_BY_TICKET, MODE_HISTORY)   ----> return TRUE (what ???);

Read the documentation...

"Note

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

if SELECT_BY_TICKET is used, MODE_TRADES and  MODE_HISTORY are ignored.

Davide Tedesco
183
Davide Tedesco  

eehhhmm just...


i hoped i read wrong....


In this way i can read from MODE_HISTORY, only with SELECT_BY_POS (then in a loop)....


i hoped that i can do it...

luckily in my EA i can can use another logic.


Well, okey, very thanks.


Have a nice day!

Davide Tedesco
183
Davide Tedesco  
Keith Watford:

Read the documentation...

"Note

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

if SELECT_BY_TICKET is used, MODE_TRADES and  MODE_HISTORY are ignored.

okey, BUT see this:


(order ticket 97944740 is open)

OrderSelect(97944740, SELECT_BY_TICKET, MODE_TRADES) = TRUE

OrderSelect(97944740, SELECT_BY_TICKET, MODE_HISTORY) = TRUE

(and this is okey, because in OrderSelect with SELECT_BY_TICKET, it find ONLY in the pool MODE_TRADES)


(order ticket 97936536 is close)

OrderSelect(97936536, SELECT_BY_TICKET, MODE_TRADES) = TRUE (false positive ???)

OrderSelect(97936536, SELECT_BY_TICKET, MODE_HISTORY) = TRUE (but then can i use mode SELECT_BY_TICKET, for find in the pool MODE_HISTORY ???)


Only the discriminating is OrderCloseTime():

if order is open OrderCloseTime()=D'1970.01.01 00:00:00' (minimal value for variable datetime type)

if order is close OrderCloseTime()=[datatime of close order]


In my EA i find if order is open with OrderSelect([int Ticket], SELECT_BY_TICKET, MODE_TRADES),

else if order is close with OrderSelect([int Ticket], SELECT_BY_TICKET, MODE_HISTORY) and i check value of OrderCloseTime()

nicholi shen
2392
nicholi shen  
enum ORDER_STATUS {STATUS_OPEN, STATUS_CLOSED, STATUS_ERROR};

ORDER_STATUS orderStatus(int ticket)
{
   if (!OrderSelect(ticket, SELECT_BY_TICKET))
      return STATUS_ERROR;
   return OrderCloseTime() > 0 ? STATUS_CLOSED : STATUS_OPEN;
}

void OnStart()
{
   int ticket = 9802232;
   printf("Ticket #%d - status=%s",
      ticket,
      EnumToString(orderStatus(ticket))
   );
}

Davide Tedesco
183
Davide Tedesco  
nicholi shen:

Wow! GOOD WORK! nicholi shen Postguy!!!


This method isn't better way for logic of my EA, but it is very good check status order method.

If you give me permis, i insert this method in my libraries.


tnx a lot!

To add comments, please log in or register