Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanaged Approach

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

    Unmanaged Approach

    Hello

    I am talking with a very experienced programmer to help me finish up a couple of projects that I am working on that actually require going to the unmanaged approach and was wondering if you could direct me to a sample strategy written with this approach. The documentation for NinjaTrader does not give very much information about all of the elements that open up as soon as you enter into unmanaged mode and so we want to make sure that all of the areas that need to be covered actually are. If there is not a sample strategy, is there at least a place that gives more documentation for it?

    Thank you very much!

    #2
    Hello jg123,

    Thank you for your post.

    The only documentation I have available is the help guide.

    There are no samples available from the forum, however I do have a sample available that might assist you with the Unmanaged. I have attached it to the post

    Let me know if I can be of further assistance.
    Attached Files
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thank you very much Cal

      Would you say that this deals with all of the criteria that is mentioned in the NT help guide?

      Are there other areas that are opened up through the unmanaged mode that are not mentioned that my coder should be aware of?

      Comment


        #4
        Jg123,

        Everything in the help guide is what is covered for the unmanaged. The difference between the order submission is that there are multiple order methods with Managed, while the Unmanaged has one method and you are establishing the orders in side it.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Hi Ninjas. I'm sorry to dig up an old thread, but I have a followup to this discussion and this has a fantastic sample from Cal for using Unmanaged orders attached to it.

          My question is about how you would handle unfilled and partial filled LIMIT orders in an unmanaged setup. Basically, exactly what Cal provided here in this example, but there is no accounting for if the market moves away from the order.

          What is the proper place to do these checks? Would you check in OnBarUpdate() if an outstanding order is partially filled or working and compare that to where the market is? Would it be better to do the partial fill check in OnExecution() or OnOrderUpdate()?

          This example gives a great framework for unmanaged orders (thanks Cal). The only thing missing for my needs would be the proper way to handle these two cases (I'll worry about overfills later).

          Using managed orders this isn't an issue because NT is smart enough to figure out what is best. To handle just the completely unfilled case, I can certainly do a check how far the market is from the limit price and cancel the order if it's too far away - I just don't want to lose the signal to execute if it moves back to that price level but the programming logic has already past that signal and will wait for the next one - not correct.

          This is more a best practices question than anything else. Thanks guys.

          Comment


            #6
            Hello,

            The best way to detect a partial fill would be within OnExecution (or OnOrderUpdate()). You can check the Order attached to the IExecution for OrderState == OrderState.PartFilled. If you detect this, then you can perform any other logic that you wish, such as canceling the remaining portion of the order if the market goes X ticks away from the order, for example.
            Dave I.NinjaTrader Product Management

            Comment


              #7
              Ok that's kind of what I figured. I guess my hangup is how to make the next trade work properly. That is, if you get a partial, allow the rest of the order to keep working, while also having the exit orders working, in the correct notionals.

              I'll just have to play with it more (and maybe share some code later). Thanks Dave.

              Comment


                #8
                A quite some time ago, I was in similar situation, it wasn't easy for a non-professional programmer like me, but at final I did a simple piece that might give some ideas. The crucial key is to re-think your Algo logic; which should be something like: "continue with the pending order until a contrary signal and at the same time update Stop-loss/profit orders actual quantity". Here for free my sample code:
                Attached Files

                Comment


                  #9
                  Thank you sir. I will work through this and let you know how it goes. Much appreciated.

                  Comment


                    #10
                    pstrusi, you are awesome. Thank you again.

                    Comment


                      #11
                      Glad to help :-) so many have helped me a lot in this awesome forum

                      Comment


                        #12
                        Ok Ninjas. I adopted the process below and was successful in building a strategy that would be long or short 153k of a currency pair at all times, using a single trade of 306k to flip direction. It backtested as expected and ran in the sim account exactly as expected.

                        However, it failed in live trading today. It did the initial trade correctly at going long 153k of a currency pair. But when it got the signal to flip, it actually sold 459k instead of 303k (3x instead of 2x the base amount). My partner was running the EXACT same code on a separate machine and it did it correctly at 303k in a sim environment.

                        The log confirms it was a single trade of 459k submitted and not the same order being submitted twice or something similar.

                        Here is the part of the code executed. I am positive it is this because of the flag "GoShort" which appears in the log. tradeQuantity is a constant set at 153,000, while Position.Quantity should have been 153,000 as well (it certainly was in the algo being run on a separate machine in a sim account).

                        How could Position.Quantity return something like this? Sync account position is set to False so that if there is a problem, another user can remotely manually execute a trade to flatten things out and not have the algo keep trying to reinstate the position. Would this cause this behavior?

                        THANKS

                        // If long
                        if (Position.MarketPosition == MarketPosition.Long)
                        {
                        if (shortEntryOrder == null && longEntryOrder == null)
                        {
                        shortEntryOrder = SubmitOrder(
                        0, OrderAction.Sell, OrderType.Limit, (tradeQuantity+Position.Quantity), (Close[0]+offerAdjust*myTickSize),0,"","GoShort");
                        }
                        // end if
                        } // end if


                        Comment


                          #13
                          Hello Locke,

                          Thank you for your post.

                          We could not say much based solely on the information provided. If we review your Log and Trace we should have a better idea. Please feel free to send us your Log and Trace by going to Help > Mail to Support, and reference this thread in the body of the e-mail: "http://ninjatrader.com/support/forum/showthread.php?t=69411"

                          Comment


                            #14
                            Thanks Patrick. Of course we lost the trace info (the Log info is fine, but doesn't really help here). We'll run it again live and when it happens again I'll save the Trace and Log and do what you suggest. Just really really weird it works fine in sim and backtesting.

                            Thanks again.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            633 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            364 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            105 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            567 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            568 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X