Thanks.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Stop Loss Orders
Collapse
X
-
Stop Loss Orders
I have a strategy that only uses a Stop Loss and so had to try to go around it to open the next order and not get an error message trying to place the stop for the next execution. As I understand all Stop Orders are named generically like "stop" or something. Maybe in the future could a strategy throw out a unique order identification for each execution and its stop and target if one is there and then make sure it closes the stop or profit or both and then move on to the next execution? Can a strategy even wait till confirmation of a cancelled order before moving on the next? Not sure so just asking.
Thanks.Tags: None
-
Hello Trader17,
Thanks for your post.
Are you trying to manually place exits to your strategy generated orders?I have a strategy that only uses a Stop Loss and so had to try to go around it to open the next order and not get an error message trying to place the stop for the next execution.
Executions already have their own unique ID.As I understand all Stop Orders are named generically like "stop" or something. Maybe in the future could a strategy throw out a unique order identification for each execution and its stop and target if one is there and then make sure it closes the stop or profit or both and then move on to the next execution?
https://ninjatrader.com/support/help...?execution.htm
You can monitor OnOrderUpdate() or OnExecutionUpdate() for cancellations. We do have a sample on our forum of monitoring those methods to submit protective orders.Can a strategy even wait till confirmation of a cancelled order before moving on the next?
https://ninjatrader.com/support/help...and_onexec.htmJosh G.NinjaTrader Customer Service
- Likes 1
-
This would all be highly dependent on the specific strategies logic. If you want to do something based on monitoring an Order fill I suggest using OnOrderUpdate(). If you want to do something only after an execution occurs than I suggest using OnExecutionUpdate()
As far as actual order handling, that is going to depend on whether you are using the "Managed" or "Unmanaged" approach to strategy development. The Managed approach offers you order methods that are wrapped with an invisible convenience layer that allows you to focus on your system's trading rules leaving the underlying mechanics of order management and the relationships between entry and exit orders and positions to NinjaTrader.
The Unmanaged approach offers you more flexible order methods without the convenience layer. This means you are not restricted to any order handling rules besides those imposed by the brokerage/exchange. With such flexibility though, you will have to ensure to program your strategy to handle any and all issues that may arise with placing orders. Please note that this approach is reserved only for experienced programmers.Josh G.NinjaTrader Customer Service
- Likes 1
Comment
-
Got it. I am not using OnExecutionUpdate() as of now in the strategy. I ask because while running in Sim it sometimes shuts itself down due to an error leaving me hanging with an open position and twice the entry quantity. So when I am using OnBarClose() to throw orders out what I am curious to know is if the entire calculation of closing open positions and opening the other happens all sort of on the same tick after close or it waits to receive confirmation on closed positions and its cancelled orders and then goes ahead and spits out the next order. So might wait for a second or two to confirm the close and cancel of previous orders before sending the new execution.
Thank you very much.
Comment
-
Trader17,
Depends on your logic and if you are connected to a live brokerage account or the SIM101I am curious to know is if the entire calculation of closing open positions and opening the other happens all sort of on the same tick after close or it waits to receive confirmation on closed positions and its cancelled orders and then goes ahead and spits out the next order.
What error are you receiving?shuts itself down due to an error leaving me hanging with an open position and twice the entry quantity.
Do you intend to throw out your order each time a bar closes?So when I am using OnBarClose() to throw orders out
How are you going about 'throwing out' the orders?
Josh G.NinjaTrader Customer Service
Comment
-
I am only testing it on a SIM101 account yet to see how it behaves. The error is about it not being able to place the stop as it is in the wrong spot. Like the buy stop is below what the market is trading at. I am still watching it though as it seems this happens in the recent lightning fast markets as price might move past where stop might be.
So when we do OnBarClose is everything done on the close right away? I am using the Managed Approach from the Strategy Builder. Nothing fancy. Like all cancel orders and new orders to open sent all on the same tick or the strategy will wait to receive confirmation all old positions and associated orders are closed out before firing the new order might be sent out a second or two later?
Comment
-
You are correct, that this happens more frequently in a fast moving market. You will likely need to increase the distance of your stop from the market, or you can add logic to your strategy to react to order rejections like these and place a market order after the rejection is received.The error is about it not being able to place the stop as it is in the wrong spot. Like the buy stop is below what the market is trading at
I'll include some publicly available documentation on handling order rejections in OnOrderUpdate() if you would like to implement such functionality in your strategy.
RealtimeErrorHandling - https://ninjatrader.com/support/help...orhandling.htm
OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm
Yes, that is correct. Your logic will execute as soon as the bar closes when using Calculate.OnBarClose.So when we do OnBarClose is everything done on the close right away?
Josh G.NinjaTrader Customer Service
Comment
-
So basically both the orders to cancel and enter a new position are sent out simultaneously and the strategy does not wait to get any type of confirmation from the exchange to make sure all old orders were closed before opening a new one, correct? And if we use OnOrderUpdate() then both the orders to close and open the new position will not be sent simultaneously? OnBarClose will wait to check all open orders are closed/cancelled and then fire the new open order out? I know all this happens in milliseconds probably.
Thank you.
Comment
-
The exchange is going to see any order submitted to it and reject or accept them. Your logic will be what decides the order of events and whether the order will be accepted or rejected. If you want your strategy to confirm an order is canceled before submitting another one then you will need to create that logic.So basically both the orders to cancel and enter a new position are sent out simultaneously and the strategy does not wait to get any type of confirmation from the exchange to make sure all old orders were closed before opening a new one, correct?
If you submit both your Orders from OnOrderUpdate() than they would both be submitted as soon as an order managed by the strategy changes state. This is assuming that your logic will allow for both submissions at the same time.And if we use OnOrderUpdate() then both the orders to close and open the new position will not be sent simultaneously?
Everything does happen in milliseconds. However, OnBarClose is only a property to the Calculate setting. If you are referring to OnBarUpdate(), it will not take any special considerations for your orders and will simply execute the logic inside.OnBarClose will wait to check all open orders are closed/cancelled and then fire the new open order out? I know all this happens in milliseconds probably.Josh G.NinjaTrader Customer Service
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
56 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
132 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
73 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|

Comment