Retrieve (stop) price of pending/non-filled order


Dear All,

Is it possible to retrieve the (stop) price for a pending / non-filled STP order? I would like to do this without using static variables, if possible.

I can retrieve my pending order by using code like this:

pendingOrderId = StaticVarGetText("pendingOrderIdKey");

I can then check if my order is really pending:

if (ibc.IsOrderPending(pendingOrderId))

If this condition is true, I would like to get the (stop) price of this order.
I need this because my strategy continuously adjusts the stop price based on some computation, and I only want to invoke ibc.ModifyOrder(…) if the newly computed price is different from the current one.

I saw in the doc that there is an IB controller method

GetExecInfo( string OrderId, , string Field)

but this seems to return a field for an order in the execution list. My order is not filled however, so it won’t show up in this list.

Any help is appreciated.


GetPendingList( number Type, string Filter )
(new in 1.0.8)

Returns comma separated list of orders from pending list - Order ID or Symbol

Since you cannot retrieve the Stop Price value from this list, you have to store it in your own list or static variable once you generate the order:

Order ID, StopPrice



As far as I understand, if I store the order ID and the stop price in static variables, these will not survive an AmiBroker restart. Is this the case? If yes, what is the best way to ensure that these variables are available even after such a restart?

More generally, what is the best pattern/approach to implement state recovery for strategies in AmiBroker? By state recovery I mean to be able to recover the order IDs, prices, and other order attributes for each product traded by a strategy.


Static variables can be set to persist (i.e. survive restart). Consult the Users’ Guide, AFL reference. It is really easy just press F1 in AmiBroker. Yes single key stroke divides you from ocean of knowledge. It works contextually so if you click on StaticVarSet and click F1 — it magically brings you to relevant doc.


Thanks Tomasz! This really makes life easy.
Am I correct to assume that using IB controller methods only it is not possible to recover order properties (like order type, price, size, etc) and one must use static vars for that?