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 rhyminkevin, Today, 04:58 PM
            4 responses
            52 views
            0 likes
            Last Post dp8282
            by dp8282
             
            Started by iceman2018, Today, 05:07 PM
            0 responses
            5 views
            0 likes
            Last Post iceman2018  
            Started by lightsun47, Today, 03:51 PM
            0 responses
            7 views
            0 likes
            Last Post lightsun47  
            Started by 00nevest, Today, 02:27 PM
            1 response
            14 views
            0 likes
            Last Post 00nevest  
            Started by futtrader, 04-21-2024, 01:50 AM
            4 responses
            50 views
            0 likes
            Last Post futtrader  
            Working...
            X