Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

exit market order repeated 30 times in strategy

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

    exit market order repeated 30 times in strategy

    Hello,

    I have a strategy I wrote which uses the unmanaged order method to open and close positions.

    Today using Tradovate and Apex Trader Funding my strategy exited a long position using a market order but executed the exit order 30 times!! That left me net short 30 mini contracts for a second or two.

    Any idea why this would happen and how to prevent it?

    #2
    Hello halgo_boulder,

    When using the unmanaged approach there are no protections against unwanted positions so its possible that was simply a result of how your logic equated at that time. The only way to know that would be to have had debugging like Print statements to trace how your logic executed. Based on that output you could know for certain what specifically happened. Looking at the log will only show that X number of orders were submitted from the strategy but would not specifically tell you why that happened. You will need to review the logic you created and ensure the order method is only called one single time during the exit conditions to make sure no additional orders are submitted.

    Comment


      #3
      OK. Do you have a simple example of order management logic using the unmanaged approach? This way I can make sure I have developed the proper order handling framework.

      Comment


        #4
        Hello halgo_boulder,

        That really depends on how your unique strategy is intended to work, there are some general samples of unmanaged strategies on the forum but they do not cover all areas of order management at once. The unmanaged approach is the api which offers the most flexibility for advanced programmers as it allows you to manage all aspects of the scripts order submission without any platform intervention.

        Comment


          #5
          Hi Jesse,

          What I'm really looking for is the best practice method for executing an unmanaged order, returning an OrderID and fill price once filled, and proper order state management until it is either filled or canceled.

          If I can track the order state properly then my code won't unnecessarily resubmit.

          Do you have any examples just that part? tracking order state and returning an orderid for unmanaged?

          Comment


            #6
            Hello halgo_boulder,

            The best practice will be what you come up with that works with what you are trying to do, the unmanaged approach is a very open framework that allows you to basically do whatever you want within the rules of your broker. You can use OnOrderUpdate and OnExecutionUpdate to track order status changes and fills. You can see a general example of using those overrides in their documentation, that applies to both managed or unmanaged.

            Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

            Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            547 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            323 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            99 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            543 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            545 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X