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!
See more
See less

Partner 728x90

Collapse

Send stop order within same bar as entry

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

    Send stop order within same bar as entry

    I have a strategy that works on CalculateOnBarClose=true. When it enters an order (mkt) at the next bar open, the strategy waits until the next bar to enter a stop order using ExitLong(Short)Stop(). Is there a simple way of sending a stop order when the entry order is filled? I don't use SetStopLoss() because the value is based on ATR and thus not fixed for the whole strategy.

    -thanks

    #2
    laparker, I think you could still use SetStopLoss with the ATR value in the OnBarUpdate() then for this. Another solution is to move this to the OnExecution() to send the stop once the entry order is filled -

    The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()
    BertrandNinjaTrader Customer Service

    Comment


      #3
      thanks Bertrand - I will experiment with using SetStopLoss(). One question I have, how do I reset this order for the next entry so it doesn't trigger before I have placed the new stop loss?

      -thanks

      Comment


        #4
        Just reset to a default value once flat like shown in the sample I referenced earlier in this thread.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Bertrand - your example relates to using OnExecution() which would be a big code change and learning curve for me. Using SetStopLoss() looks like I can keep within OnBarUpdate() but I don't see how to cancel the previous SetStopLoss(). Do I include a new SetStopLoss() order when flat and before the new entry order and if so, what do I use as the value?

          -thanks

          Comment


            #6
            You cannot cancel a previous Set() order. All you can do is change the value you will be submitting the stop at prior to your next entry.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Segwin, 05-07-2018, 02:15 PM
            14 responses
            1,788 views
            0 likes
            Last Post aligator  
            Started by Jimmyk, 01-26-2018, 05:19 AM
            6 responses
            837 views
            0 likes
            Last Post emuns
            by emuns
             
            Started by jxs_xrj, 01-12-2020, 09:49 AM
            6 responses
            3,293 views
            1 like
            Last Post jgualdronc  
            Started by Touch-Ups, Today, 10:36 AM
            0 responses
            13 views
            0 likes
            Last Post Touch-Ups  
            Started by geddyisodin, 04-25-2024, 05:20 AM
            11 responses
            63 views
            0 likes
            Last Post halgo_boulder  
            Working...
            X