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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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: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:
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 judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
53 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
33 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
5 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
19 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
6 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Comment