PDA

View Full Version : ATI StrategyPosition DLL Function Usage


whitmark
09-25-2007, 03:26 PM
I would like to identify the best practice for determining whether an ATI-submitted ATM strategy (with unique strategyID) is flat after previously being in a position.

Confirming whether an entry order has been filled is easy enough using the Filled(orderID) or OrderStatus(orderID) functions, where the orderID is obtained when the order is placed. However, determining whether a ATM-submitted Stop or Target exit order has been filled or that the ATM StrategyID is flat, is more difficult. As can be seen in the attached tick-by-tick log of orders placed on the ES continous contract, there is a small lag (albiet subsecond) between when the entry order is filled and when the StrategyPosition function recognizes a position is on (e.g., 1 or -1 vs 0). The challenge, of course, is that there is no way to directly and definitively query the DLL interface tick-by-tick to determine whether a once long or short position is now flat.

2007/09/25 16:32:40 #14591 T 15 Symbol: ES ##-## LastOrdID: 3CDE3865F97D40399C54A7132E23D136 OrdStatus: Working OrdFill: 0 FillPrice: 0.00 StratPos: 0
2007/09/25 16:32:40 #14591 T 16 Symbol: ES ##-## LastOrdID: 3CDE3865F97D40399C54A7132E23D136 OrdStatus: Working OrdFill: 0 FillPrice: 0.00 StratPos: 0
2007/09/25 16:32:40 #14591 T 17 Symbol: ES ##-## LastOrdID: 3CDE3865F97D40399C54A7132E23D136 OrdStatus: Working OrdFill: 0 FillPrice: 0.00 StratPos: 0
2007/09/25 16:32:40 #14591 T 18 Symbol: ES ##-## LastOrdID: 3CDE3865F97D40399C54A7132E23D136 OrdStatus: Filled OrdFill: 1 FillPrice: 1529.00 StratPos: 0
2007/09/25 16:32:40 #14591 T 19 Symbol: ES ##-## LastOrdID: 3CDE3865F97D40399C54A7132E23D136 OrdStatus: Filled OrdFill: 1 FillPrice: 1529.00 StratPos: 0
2007/09/25 16:32:40 #14591 T 20 Symbol: ES ##-## LastOrdID: 3CDE3865F97D40399C54A7132E23D136 OrdStatus: Filled OrdFill: 1 FillPrice: 1529.00 StratPos: 1
2007/09/25 16:32:50 #14592 T 1 Symbol: ES ##-## LastOrdID: 3CDE3865F97D40399C54A7132E23D136 OrdStatus: Filled OrdFill: 1 FillPrice: 1529.00 StratPos: 1
2007/09/25 16:32:50 #14592 T 2 Symbol: ES ##-## LastOrdID: 3CDE3865F97D40399C54A7132E23D136 OrdStatus: Filled OrdFill: 1 FillPrice: 1529.00 StratPos: 1

Is there any other tactic I can use in the calling code to know when my ATI-submitted ATM strategy is flat or do I just need to wait N ticks or N seconds once the entry is filled and before I query the StrategyPosition function? Perhaps there is a way to obtain the ATM stop and target order IDs and query their status directly? Thanks.

Regards,

Whitmark

NinjaTrader_Ray
09-25-2007, 07:10 PM
You have to wait once the entry is filled and then check for status on the strategy.

You can not retrieve order id values of ATM strategy generated stop/target orders.

whitmark
09-25-2007, 10:57 PM
You have to wait once the entry is filled and then check for status on the strategy.

Thanks Ray, I thought so too but as I show in the exhibit in the previous post, on tick #18 the entry order is confirmed to be filled (via the Filled function) but not until tick #20 does the StrategyPosition indicate that the position is long. So it seems like a delay is needed even after the entry order is filled. This example is using the Sim101 account . . . I'll have to see what the lag is on a live brokerage account. Thoughts?

Regards,

Whitmark

NinjaTrader_Ray
09-26-2007, 07:04 AM
Your experience is possible. Different brokerages can also have differnent experiences since there never a guarantee in which order order states and executions (which drive our position objects) come in from the broker.