• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Disable Strategy on Stop Fill

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    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?

    #2
    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.
    https://ninjatrader.com/support/help...sestrategy.htm

    You could choose to call this in OnOrderUpdate() or OnExecution() when the order.Name is "Stop loss" and the OrderState is .Filled.
    https://ninjatrader.com/support/foru...092#post786092
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      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


        #4
        Hello The Big D,

        No, calling CloseStrategy() is fine to do from OnOrderUpdate().

        It will close all positions and cancel all orders, even newly submitted ones.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by SAILIKITY, 05-22-2019, 05:41 PM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by rmillar, 01-09-2019, 06:02 PM
        6 responses
        58 views
        1 like
        Last Post eDanny
        by eDanny
         
        Started by mlarocco, Today, 11:39 AM
        4 responses
        19 views
        0 likes
        Last Post mlarocco  
        Started by roblogic, Today, 11:19 AM
        2 responses
        14 views
        0 likes
        Last Post roblogic  
        Started by saeed, Today, 10:17 AM
        8 responses
        39 views
        0 likes
        Last Post NinjaTrader_Kate  
        Working...
        X