In the event that the stop executes, I want to shut down the strategy or at least ensure no more Enter*() methods are called. It appears that the right way to do this is call CloseStrategy(). How can I detect that the stop has executed in the context of the managed approach?
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
Disable Strategy on Stop Fill
Collapse
X
-
Disable Strategy on Stop Fill
I've got a strategy that is using the managed order approach. It enters positions with EnterLong() and EnterShort() and exits them with ExitLong() and ExitShort(). In addition it sets a stop with SetStopLoss().
In the event that the stop executes, I want to shut down the strategy or at least ensure no more Enter*() methods are called. It appears that the right way to do this is call CloseStrategy(). How can I detect that the stop has executed in the context of the managed approach?Tags: None
-
Hello The Big D,
I would not recommend using multiple exit orders on the same entry.
That said, CloseStrategy() would be correct to disable the strategy.
You could choose to call this in OnOrderUpdate() or OnExecution() when the order.Name is "Stop loss" and the OrderState is .Filled.
Chelsea B.NinjaTrader Customer Service
-
Chelsea,
Thanks for your response. The code example in your second link is very helpful. Do I have to be concerned that OnOrderUpdate() may be called in the middle of OnBarUpdate()? If so, do I need to protect any variables shared between the two with some sort of mutex?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by jpapa, Today, 07:22 AM
|
1 response
5 views
0 likes
|
Last Post Today, 07:34 AM | ||
Started by kevinenergy, 02-17-2023, 12:42 PM
|
116 responses
2,758 views
1 like
|
Last Post
by kevinenergy
Today, 07:23 AM
|
||
Started by franatas, 12-04-2023, 03:43 AM
|
7 responses
106 views
0 likes
|
Last Post Today, 07:23 AM | ||
Started by Jltarrau, Today, 05:57 AM
|
3 responses
9 views
0 likes
|
Last Post
by Jltarrau
Today, 07:22 AM
|
||
Started by f.saeidi, Today, 05:56 AM
|
2 responses
9 views
0 likes
|
Last Post Today, 07:17 AM |
Comment