Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Retrieving partially filled OCO orders
Collapse
X
-
Retrieving partially filled OCO orders
Hi, I would like to have the capacity to cancel seed order if attachment of a stop-loss or a stop-limit order rejection (bracket orders hygiene). I could do so by using FromEntrySignal, however it may cause trouble in case of partial fills. How would I get an NT token id of seed order or uniquely identify a partially filled order in any other way?Tags: None
-
I just thought about it again. If you are asking about partial fills from your bracket orders you should still be able to check for OrderState. Make sure you use IOrder for all of them and then you can manage them however you want. CancelOrder() can be used to cancel any orders.Josh P.NinjaTrader Customer Service
Comment
-
As far as I understand the only way for me to retrieve seed order from order info on a bracket order is by using IOrder.FromEntrySignal. However, if seed order was filled in parts then I'll get the collection of these partial fills by the order name. In which case I won't know which part exactly to cancel (e.g. to which part of the filled order named IOrder.FromEntrySignal is given bracket attached).
Why this concern: I am thinking here of two things. First, I could cancel wrong part of filled signal, and the one with diverted brackets will stay in. Second, I don't want to prematurely cancel the part of seed order with the best filled price, if I choose that part randomly or at NT will.
PS. I should probably clarify that I attach brackets upon order having been filled in OnExecution() method
Comment
-
Not sure what you mean by "seed" orders. You should know exactly which orders correspond with which orders if everything has its own IOrder. You keep track of this simply by giving them names that correlate with each other. Please see the reference sample about OnOrderUpdate() and OnExecution(). If you have an order partially filled and then the exchange receives your CancelOrder() obviously it can only cancel what is remaining of that order. This is what you would normally expect.
You do EnterLongLimit(). Then you protect it with say ExitShortLimit(). Enter is partially filled. Then Exit will protect the portion that gets filled accordingly. You decide you no longer want remainder of Enter order. Simply Cancel the Enter order. Exit order should simply follow suit because it has no matching position.Last edited by NinjaTrader_JoshP; 07-12-2008, 06:15 PM.Josh P.NinjaTrader Customer Service
Comment
-
what I mean by 'seed order' is the order to which a bracket order is attached. Now, I won't mind NT cancelling remainders of that order, but... To be more explicit, let's say size of a seed order named 'myOrder' was 100, it was partially filled in two steps, first 80 shares and then 20 more shares. When attaching brackets in OnExecute(), I see that the bracket order to be attached to the last portion of the seed order (20 shares) was rejected for some reason. Now out of order 'myOrder' I want to cancel only those 20 shares whose bracket was diverted (not any other 20 shares contained in 'myOrder'), and not the entire order (as 80 shares are already traded successfully and I want to keep this position). How do I do this?
Referring to the correction, I think I can't place ExitLongLimit() at the same time with EnterLong() since the position doesn't exist yet; I can do so only upon seed oder execution.Last edited by billitin; 07-12-2008, 06:31 PM.
Comment
-
So you mean your order is already completely filled. In this situation you are not talking about cancelling an order anymore. What you need to do is now either protect that remaining unprotected 20 shares or get rid of it. The only way to do this is simply reattach the order that got cancelled to the entry order. Calculate out that you have 20 unprotected shares and attach it to the same entrySignal.Josh P.NinjaTrader Customer Service
Comment
-
Yes, that's exactly what's happening. Here comes another side of the problem though. I would also like to keep track of all orders and store references to them somewhere due to a workaround (I do it to manage trading on both sides of market, so I had to split my strategy into long and short parts but still I need some common control over the two separate parts; also on close NT wipes out other positions for the same security places out of NT and I'd like to preserve them).
How it's supposed to work: once a seed order gets filled from some strategy in OnOrderUpdate I insert a reference to it into my order storage, and once it gets sold short or bought to cover (due to a bracket order) I delete its reference from there. So I need to precisely how much of each seed order is left in an open position, and the easiest way to do so would be not calculating numbers of shares in and shares out, but simply go by seed order reference. From what I know order token is a unique order reference in NT, so all I want is to get hold of a seed order
token from IExecute that's called upon a bracket attached to it.
To develop the thought: imagine the last 20 shares piece's bracket order got filled in parts, too. But the seed order already has its unique token id generated. Does this mean there's no way to know to which part of those 20 seed shares a partially filled bracket corresponding? Or there's some other mechanism of knowing what a filled bracket order corresponds to, rather than by looking the seed order token id?Last edited by billitin; 07-12-2008, 07:05 PM.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
646 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
367 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
107 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
569 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment