OrderType problem

[Deleted]  
My EA has a problem identifying open orders correctly, and to test the logic I made a small program that checks if there is an open order and if so, is it buy or sell.
The program is as follows:

if (OrdersTotal()==1)
{
if (OrderType()==OP_BUY) Comment("Buy");
if (OrderType()==OP_SELL) Comment("Sell");
}
else
{
Comment("No Order");
}

If there are no open orders it comments correctly, No Order.
The problem is if there is an open order the comment is "Buy" regardless of whether it is a buy or sell order. Why is that?
Please tell me what I'm doing wrong here.


Thanks,
Rayner
[Deleted]  
You have to call OrderSelect() before you can call any of the order query functions like OrderType().
[Deleted]  
Craig:
You have to call OrderSelect() before you can call any of the order query functions like OrderType().

Thanks Craig, works like a charm :)