How to detect a limit order is filled

Hi,

I am using AFL to develop some autotrade program using “AmiBroker Auto-Trading interface for Interactive Brokers” to interface with my IB account. (http://www.amibroker.com/at/ )

In the program, after placing a limit order to buy or sell something, I use GetStatus( string OrderId, [optional] boolean InclFilled ) to continuously check whether the order is fulfilled or not. I check the status to be “Filled” and the inclFilled I set to True.

However, from time to time, I found that in my IB account, the order is actually filled, yet I cannot detect the “Filled” status, although I already set the “inclFilled” field to be True. That screws up my program.

Do you have any idea what could possibly cause such abnormal behavior?

Can you tell me is there any better method (in AFL) to detect the fulfillment of a limit order?