Problem with OrderSelect

 
I have this:

OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES)

It is supposed to return FALSE is I dont have such a ticket on the Trade Panel as defined by documents:

bool OrderSelect(int index, int select, int pool=MODE_TRADES)

Selects order by index or ticket to further processing. If the function fails, the return value will be false. To get the extended error information, call GetLastError().
Parameters
index - Order index or order ticket depending from second parameter.
select - Selecting flags. It can be any of the following values:
SELECT_BY_POS - index in the order pool,
SELECT_BY_TICKET - index is order ticket.
pool - Optional order pool index. Used when select parameter is SELECT_BY_POS.It can be any of the following values:
MODE_TRADES (default)- order selected from trading pool(opened and pending orders),
MODE_HISTORY - order selected from history pool (closed and canceled order).




My script created the Order and knows the ticket number.
2006.11.06 09:50:13 Script GBPUSD,M5: open #5887942 buy stop 1.00 GBPUSD at 1.9025 sl: 1.9000 tp: 1.9050 ok


After a while, I deleted the Order which should make the OrderSelect not finding the order anymore. However, it still sees the ORDER and no Error is returned.

2006.11.06 09:51:21 Script GBPUSD,M5: unknown ticket 5887942 for OrderModify function


Sometimes it works oftentimes it doesnot.

Anyway for knowing if a particular Ticket is deleted or not? How do I ensure 100% of the time that OrderSelect will properly identify that a particular Order is still in the Trade Panel or is already removed/closed?
 
Isn't "unknown ticket" an error?
How do you tell the OrderSelect function which ticket to select? The problem may be there.
 
Anyway for knowing if a particular Ticket is deleted or not? How do I ensure 100% of the time that OrderSelect will properly identify that a particular Order is still in the Trade Panel or is already removed/closed?


Here is a hint:
Open orders have OrderCloseTime() set to 0.
Reason: