From my strategy, I am placing profit target order using ExitLongLimit and stop order using ExitLongStopMarket by passing the same entry signal name as fromEntrySignal. When the Profit target is filled, the stop order will be closed automatically ? Similarly when the stop order is filled, the profit target will be closed automatically ? OR from my strategy i need to cancel it explicitly . Kindly clarify.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
ExitLongLimit and ExitLongStopMarket order with same entry name
Collapse
X
-
ExitLongLimit and ExitLongStopMarket order with same entry name
Hi,
From my strategy, I am placing profit target order using ExitLongLimit and stop order using ExitLongStopMarket by passing the same entry signal name as fromEntrySignal. When the Profit target is filled, the stop order will be closed automatically ? Similarly when the stop order is filled, the profit target will be closed automatically ? OR from my strategy i need to cancel it explicitly . Kindly clarify.
Tags: None
-
Hello nandhumca,
Thank you for your post.
Since you are using the fromEntrySignal parameter for the ExitLongLimit and ExitLongStopMarket orders with the same entry signal name, once one of those orders fills and the position is closed the other order will be canceled with the reasoning "Cancelled pending exit order, since associated position is closed."
For some additional information related to orders and when they are canceled, the default behavior is for an order to be canceled if the conditions to trigger that order are no longer true. Otherwise, there is an option for orders to be live until canceled if the isLiveUntilCancelled bool is set to true in the order method. The following reference sample explains the difference between the two and there is more info about live until canceled orders in the Advanced Order Handling section of the help guide:Please let us know if we may be of further assistance.
-
if i place order only with fromEntrySignal and without setting isLiveUntilCancelled and the PT/SL didn't get filled on the same bar, it is getting closed automatically at the end of the bar. I want to this to be in live until either PT/SL hits. Kindly help to achieve on this.
Comment
-
Hello nandhumca,
That would be expected, when you do not use IsLiveUntilCanceled on an order that rests at a specific price the order will expire after 1 OnBarUpdate event. You need to keep calling the order method to keep it alive until filled. You can see a sample of that concept in the following strategy builder samples: https://forum.ninjatrader.com/forum/...rategy-builder
You otherwise need to use IsLiveUntilCanceled if you plan to submit the order one time and wait for it to be filled.
Comment
-
Hello nandhumca,
The opposing order can be cancelled in OnExecutionUpdate() (or OnOrderUpdate()).
Below is a link to the ProfitChaseStopTrailExitOrdersExample example which has sample code.
https://forum.ninjatrader.com/forum/...ing#post802269
If you want to adjust the quantity after a part fill, this example has sample code.
Chelsea B.NinjaTrader Customer Service
Comment
-
One more question . When I tested the order with IsLiveUntilCanceled as per the example you have shared, i am seeing below case where both SL and PT order moved to filled state and in PT order there is -1 remaining order. Is that expected ? how to handle it in code ?
Comment
-
Hello nandhumca,Originally posted by nandhumca View PostIf i set IsLiveUntilCanceled= true and an unique value as OCO for both PT and SL , will that work as oco order ? If i set oco for both PT and SL , do I still need to cancel the opposing order ?
Thank you for your responses.
When using Exit() orders in the Managed Approach, setting an OCO value is not an option. OCO is only applied to stops and targets created via Set() methods like SetStopLoss() and SetProfitTarget(). My colleague Chelsea specifically mentioned the ProfitChaseStopTrailExitOrdersExample because this contains logic in OnOrderUpdate() to try and simulate OCO using the Managed Approach and Exit() orders. Please see the logic starting at line 251 with the code comment "// the logic below is to simulate OCO when manually cancelling an order." to see how this was achieved in that example. In your example where both the stop loss and profit target filled with a remaining quantity of -1, I suggest adding Print() statements to your strategy to better understand its behavior and make sure it is behaving as expected. The ProfitChaseStopTrailExitOrdersExample contains Print statements throughout to help explain what actions are being taken so you can understand which parts of the logic are being hit and why. You will need to do something similar in your strategy to understand why both orders were filled so you may adjust your logic to prevent that from happening in the future. Fore more details on using prints to debug your script's behavior:
Please let us know if we may be of further assistance.
Comment
-
If you call CancelOrder() for an order that was already canceled in simulation, nothing happens. There is no order to be canceled and no errors come up. The following reference sample shows how to submit stops and targets for partial fills:Originally posted by nandhumca View PostThanks Emily. What will happen if i cancel a order again which is already cancelled ?- https://ninjatrader.com/support/help...and_onexec.htm
- See the logic starting at line 127 for details on how stops and targets are handled for partial fills
Comment
- https://ninjatrader.com/support/help...and_onexec.htm
-
Thanks Emily for the sample one partial filled order. In that sample ExitLongStopMarket and ExitLongLimit are placed multiple times for each part-filled event with same entry signal. The subsequent ExitLongStopMarket and ExitLongLimit with same entry name will be considered as new order or it will be update on existing active order with same entry signal ?
Comment
-
The subsequent stop and target orders (ExitLongStopMarket and ExitLongLimit) will be updated in the case of partial fills. Each time additional contracts are filled, you will see a status of "Change submitted" for the MyStop and MyTarger orders on the Log tab of the Control Center in order to change the quantity of the orders. This is something you may test on your end as well to observe how the orders behave, and you could even print out the OnOrderUpdate() information or enable TraceOrders as a debugging tool in order to better understand the strategy's behavior.Originally posted by nandhumca View PostThanks Emily for the sample one partial filled order. In that sample ExitLongStopMarket and ExitLongLimit are placed multiple times for each part-filled event with same entry signal. The subsequent ExitLongStopMarket and ExitLongLimit with same entry name will be considered as new order or it will be update on existing active order with same entry signal ?
Please let us know if we may be of further assistance.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
44 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
124 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
65 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment