Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Holding orders in strategy somehow when waiting for fills & cancels (managed orders)

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

    Holding orders in strategy somehow when waiting for fills & cancels (managed orders)

    Using the managed order mode, I have strategies that run fine using a "pending" flag to hold orders back when waiting for fills or cancels to come back from the broker.

    I suspect that overnight in the less liquid instruments, e.g. NZD-USD forex, the market can be really slow and in rare circumstances I think my strategy wants to change its orders even before it's had a chance to submit the previous orders.

    In other words I think I might be hanging on to "pending" orders (not even submitted) when the strategy decides to change them. This seems a bit complex to code for, but OK, however what if it decides to cancel and replace them?

    And what if the strategy decides on a third change? Do I need to build up a queue of orders or somehow write logic to maintain a grip on what's going on, or do I just shut down the strategy at that point?

    What's recommended? I haven't seen anything useful by searching here that is coded up already.

    What would be the best way to stop the strategy? Can I invoke the automated stop that happens when an order is rejected?

    #2
    adamus, if an order is rejected, the strategy is per default terminated - you can code your own rejection handling if you disable this RealtimeErrorHandling - http://www.ninjatrader-support.com/H...rHandling.html

    Comment


      #3
      Hi Bertrand,

      I don't want to deal with rejected orders - I just want to use the same mechanism in my script if I decide I want to terminate the strategy, for those reasons. Is that functionality available in NinjaScript?

      Comment


        #4
        adamus, if you want to halt the strategy then the ideas shown in this reference sample would be of help - http://www.ninjatrader.com/support/f...ead.php?t=4804

        You could also submit an order that you know would be rejected to trigger the default error handling terminating the strategy, but the above approach is the preferred one.

        Comment


          #5
          I can't find any info on Position.Close().

          Will this call simply close my position with a market order?

          Thanks

          Comment


            #6
            adamus, this is unfortunately unsupported NinjaScript - but, correct it would be a market order closing the position.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            576 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            553 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X