Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanaged Order Approach Examples

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

    Unmanaged Order Approach Examples

    Hi,

    Is there a collection of sample/reference strategies that illustrates how to use the unmanaged order approach in advanced scenarios which also illustrates all the things one would need to be concerned about vs using the managed approach? Is there something like that you can point me to?

    Thanks,
    FaaastEddy

    #2
    Hello FaaastEddy,

    Thanks for your post.

    You can read about the Unmanaged Approach following the documentation below. I have also attached an UnmanagedTemplate strategy which follows the same techniques as SampleOnOrderUpdate.

    Unmanaged Approach - https://ninjatrader.com/support/help...d_approach.htm

    SampleOnOrderUpdate (to compare with Unmanaged Template strategy) - https://ninjatrader.com/support/help...and_onexec.htm

    Unmanaged allows you to have full control over OCO and Overfilled orders, but removes the framework of the Managed Approach. We essentially just tell NinjaTrader to submit orders to buy and sell. SellShort and BuyToCover would be order types to enter short and close short positions, but the premise is essentially the same that we do not Enter/Exit, we just Buy/Sell.

    Let us know if you have any additional questions.

    Attached Files

    Comment


      #3
      Hi Jim,

      Thanks for the UnmanagedTemplate sample code, its quite helpful to understand how to use the Unmanaged Order Approach.

      I have a question regarding order references. The sample has a comment in the OnOrderUpdate() method that indicates its more reliable to assign order objects there than in the OnBarUpdate() method. The reason provided is: "as the assignment is not guaranteed to be complete if it is referenced immediately after submitting". I want to double check if I get this point. As an example, you assign the order object that is returned from the unmanaged order submission call to an order entry variable in the OnBarUpdate() method. Then on the next line, you try to use it - is this is the unreliable case? If so why? The code is not async, so I assume after the order object assignment it should be there by the time the next line of code is processed. Or am I going down the wrong path in thinking what that comment means? When would you use the order object that is returned from the unmanaged order submission method? in the sample provided it's not assigned there but assigned in the OnOrderUpdate() instead.

      Comment


        #4
        Hello FaaastEddy,

        Your understanding is correct. The trying to use the order on the next line will either be the incorrect order, unreliable information, or will fail with an error.

        The code is async. OnBarUpdate runs from the data thread. OnOrderUpdate runs from the order thread. These are not synchronous.

        Below are links to the help guide.
        https://ninjatrader.com/support/help...rderupdate.htm
        https://ninjatrader.com/support/help...nbarupdate.htm

        Where you have inquired:
        "When would you use the order object that is returned from the unmanaged order submission method?"

        The answer is never. Always use the order object from OnOrderUpdate as advised in the help guide.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi,

          I'm wondering if there is an updated/newer version of 'Unmanaged_Template" for detailed example on how to code around Unmanaged Approach strategy development.

          Thank You.

          Comment


            #6
            Hello FaaastEddy,

            Thanks for your note.

            We do not have an updated/newer version of the script shared by NinjaTrader_Jim.

            The same unmanaged approach methods would be used in an updated script as the ones you see in the UnmanagedTemplate example shared by NinjaTrader_Jim on post # 2.

            Unmanaged Approach: https://ninjatrader.com/support/help...d_approach.htm

            You could view the attached example that NinjaTrader_Jim shared and the attached script, UnmanagedOCOBracketExample, which you might find helpful.
            Attached Files
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment


              #7
              Originally posted by NinjaTrader_Jim View Post
              In this sample, for both long and short stop placement, there is this code (for long):

              Code:
                                  ...
                                  else
                                  {
                                      // Submit exit orders for partial fills
                                      if (execution.Order.OrderState == OrderState.PartFilled)
                                      {
                                          ChangeOrder(stopLossLong, execution.Order.Filled, 0, execution.Order.AverageFillPrice - StopDistance * TickSize);
                                          ChangeOrder(targetLong, execution.Order.Filled, execution.Order.AverageFillPrice + ProfitDistance * TickSize, 0);
                                      }
                                      // Update our exit order quantities once orderstate turns to filled and we have seen execution quantities match order quantities
                                      else if (execution.Order.OrderState == OrderState.Filled  &&  sumFilledLong == execution.Order.Filled)
                                      {
                                          // Stop-Loss order for OrderState.Filled
                                          ChangeOrder(stopLossLong, execution.Order.Filled, 0, execution.Order.AverageFillPrice - StopDistance * TickSize);
                                          ChangeOrder(targetLong, execution.Order.Filled, execution.Order.AverageFillPrice + ProfitDistance * TickSize, 0);
                                      }
                                  }
              Both conditionals do the same thing, so why is it separated?

              Comment


                #8
                Is there an Unmanaged Template example without OCO?

                Comment


                  #9
                  Hello AgriTrdr,

                  I am not aware of a specific unmanaged example that does not use OCO, you can use unmanaged more or less just like the managed approach when not specificing OCO. You just use SubmitOrderUnmanaged, when entering the OCO you just leave the string blank if you dont want OCO.

                  Comment


                    #10
                    I attempted to take the OCO example and turn it into Non-OCO. The modifications that I added are to Cancel a Limit order if there is signal on the opposite side and Exit a current filled order if there is a signal on the opposite in OnOrderUpdate(). The strategy is submitting Internal Orders in the Output window, but nothing on the chart.

                    Please see the attached .cs file.
                    Attached Files

                    Comment


                      #11
                      Hello AgriTrdr,

                      You mentioned adding other logic to the script which may be the problem. Have you tried a more simple test where you are not trying to cancel the order based on the order events? Because you modified the code you may need to add Print statements now to make sure those changes are valid and you are not trying to immediately cancel the order as soon as its submitted.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      581 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      338 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      103 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      554 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      552 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X