how can you cancel the the remaining open porportion, without effecting the stop and target orders that are live for the filled proportion
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Cancelling the remained of a partial fill
Collapse
X
-
Cancelling the remained of a partial fill
if i have an entry order which is only partially filled - which triggers stop/target orders upon execution
how can you cancel the the remaining open porportion, without effecting the stop and target orders that are live for the filled proportionTags: None
-
Hello,
You can accomplish this through advanced order handling through checking within the OnOrderUpdate() event method when a partial fill has occurred for the entry IOrder object.
For more information on OnOrderUpdate() please see the following link: http://ninjatrader.com/support/helpG...rderupdate.htm
For more information on the IOrder objects please see the following link: http://ninjatrader.com/support/helpG...nt7/iorder.htm
I would also recommend to review the following reference sample on cancelling orders and using the OnOrderUpdate() event method: http://ninjatrader.com/support/forum...ad.php?t=18890
If we can be of any other assistance please let us know.Cody B.NinjaTrader Customer Service
-
Hello,
I have provided an example of how you could do this below:Please let me know if you have any questions about the example.Code:private IOrder entryOrder = null; protected override void Initialize() { CalculateOnBarClose = true; SetStopLoss(CalculationMode.Ticks, 20); SetProfitTarget(CalculationMode.Ticks , 10); } protected override void OnBarUpdate() { if(Historical) return; if(Close[0] > Open[0]) { entryOrder = EnterLong(10 , "myEntry"); } } protected override void OnOrderUpdate(IOrder order) { if(entryOrder != null && entryOrder == order) { if(order.OrderState == OrderState.PartFilled) { CancelOrder(entryOrder); } } }Cody B.NinjaTrader Customer Service
Comment
-
thanks for example.
rather than cancel immediately if i only get a part fill in OnOrderUpdate, what i am trying to do is cancel an entry order (the whole order or the remaindering proportion if i have got a part fill ) if the bid gets above the entry price by a certain level ( ie to cancel the order if i missed an entry fill and market gets too far away)
How do i check the orderstate of the entry order from within the OnBarUpdate section
if (entryOrder != null
&& entryOrder == Orderstate.Working // dont think this is correct
&& LongOrder == true
&& GetCurrentBid() < EntryLine +.10)
{
CancelOrder(entryOrder);
}
Comment
-
Hello,
I have provided below an example on how you can check the order state of the entryOrder and if it is still working:
Please let me know if you have any questions on the example.Code:protected override void OnOrderUpdate(IOrder order) { if(entryOrder != null && entryOrder == order) if(order.OrderState == OrderState.Working //DoSomething } }Cody B.NinjaTrader Customer Service
Comment
-
Cody - can you provide example that would work in OnBarUpdate for each new tick
the example you have provided is for the OnOrderUpdate which will not check the condition often enough as it would only work when their is a change in the order.
i am having difficult applying your example to OnBarUpdate
Comment
-
Hello,
You can check the orderstate of an IOrder object by checking its property. For more information on the IOrder properties please see the following link: http://ninjatrader.com/support/helpG...nt7/iorder.htm
Please see the example below to check the order state in OnBarUpdate:
Code:private IOrder entryOrder = null; protected override void OnBarUpdate() { if(SMA(20)[0] > EMA(20)[0] && entryOrder == null) entryOrder = EnterLong(); if(entryOrder != null && entryOrder.OrderState == OrderState.Working) //DoSomething }Cody B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
640 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
366 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
572 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment