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

Cancelling orders once placed

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

    Cancelling orders once placed

    When a limit order is submitted in a strategy and not necessarily filled but needs to be cancelled, how does one do that?

    For example, the strategy determines a condition where we want to place a buy stop limit to wait for the condition to play out but then the signal goes away. Enter order:
    EnterLongStopLimit( 1, entryPrice, entryPrice, "tagLongOrderT1" );

    How does that get cancelled if we know the signal is lost? I've looked at CancelOrder(IOrder order), but it sounds like I shouldn't use that. Does ExitLong(string fromEntrySignal) cancel the order if it is not filled?

    #2
    All you have to do to cancel a limit order is let it expire by not resubmitting it on the next OnBarUpdate().
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      You mean an order is only good for the life of the current bar? If that's true, how do I place an order and let it sit until it gets filled or I determine it needs to be cancelled?

      Comment


        #4
        By default you need to keep resubmitting it on every single bar you want the order to be active. The moment you stop doing so, it will expire and be cancelled.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          OK, so how, not by default, do I place the order to stay until I say so? In this strategy, I'm setting up a condition that will come true in a future bar.

          Comment


            #6
            Use liveUntilCancelled = true overload method for the order and then use CancelOrder.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by somethingcomplex, Yesterday, 10:36 PM
            1 response
            23 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by rayyyu12, Today, 12:47 AM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by guyonabuffalo, Yesterday, 10:01 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by thumper57, Yesterday, 04:30 PM
            3 responses
            12 views
            0 likes
            Last Post thumper57  
            Started by DT215, 01-14-2023, 07:59 PM
            4 responses
            132 views
            1 like
            Last Post NinjaTrader_BrandonH  
            Working...
            X