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

Reliability of managed vs unmanaged Advanced order handling

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

    Reliability of managed vs unmanaged Advanced order handling

    I would like to open a discussion regarding advantages and disadvantages of the managed - unmanaged execution for reliability. I am an experienced programmer.
    My only concern is the reliability, that is the ability to let it run with minimum monitoring.
    The strategy is simple, it has two brackets and I am inclined to use the managed method. I would use set stop loss and profit target and I would know how to code it.
    The question really is, whether managed method is sufficiently reliable to be able to handle partial fills and real time situations.
    Any comment is appreciated.

    #2
    Hello giogio1,

    Thanks for your post.

    We recommend to always monitor a NinjaScript strategy that is enabled and running incase unexpected behavior or errors happen to occur when the script is running.

    That said, please see the information below noted in the help guide in regard to Unmanaged Approach vs Managed Approach.

    In place of the convenience layer that the Managed Approach offers, the Unmanaged approach instead offers ultimate flexibility in terms of order submission and management. This means you are not restricted to any order handling rules besides those imposed by the brokerage/exchange. With such flexibility though, you will have to ensure to program your strategy to handle any and all issues that may arise with placing orders.

    The Managed approach offers you order methods that are wrapped with an invisible convenience layer that allows you to focus on your system's trading rules leaving the underlying mechanics of order management and the relationships between entry and exit orders and positions to NinjaTrader. The cost for having the convenience layer is that there are order handling rules that must be followed to prevent order errors.​

    See the help guide documentation below for more information.

    Managed Approach: https://ninjatrader.com/support/help...d_approach.htm
    Unmanaged Approach: https://ninjatrader.com/support/helpGuides/nt8/unmanaged_approach.htm

    This forum thread will be open to other community members to share their insights on the topic as well.
    Last edited by NinjaTrader_BrandonH; 10-09-2023, 08:23 AM.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thank you Brandon for your reply. If I understand correctly, aside the flexibility in terms of order submission and management, no higher reliability of the system can be obtained with the unmanaged approach if coded properly. Do I understand correctly?
      For reliability I only refer to
      -probability of having position partially closed thus leaving unwanted positions open
      -mismatches between the strategy's knowledge of opened positions and the positions actually opened in the account.
      -handling of faulty connections.
      I will monitor the strategy but I'd like to reduce errors to the very minimum.

      Additionally, I read somewhere in the Ninjatrader help guides an all discussion regarding the managing of partial fills and choices we may have, but I can not longer locate it.
      Best
      G

      Comment


        #4
        Hello G,

        Thanks for your notes.

        Your understanding is correct. If coded properly there would not necessarily be a higher reliability between Managed Approach and Unmanaged Approach aside from the flexibility of order management in the Unmanaged Approach.

        OnExecutionUpdate() could be used to submit Exit order for partial fills and update our exit order quantities once order state turns to filled.

        OnExecutionUpdate(): https://ninjatrader.com/support/help...tionupdate.htm

        See this help guide page for information regarding StopTargetHandling: https://ninjatrader.com/support/help...ethandling.htm

        Here is a help guide page about NinjaScript Best Practices: https://ninjatrader.com/support/help..._practices.htm

        See this help guide documentation detailing Strategy Position vs Account Position (Strategy positions are separate from actual Account positions): https://ninjatrader.com/support/help..._account_p.htm

        In regard to keeping your strategy from disabling when losing a connection by changing how NinjaTrader controls the NinjaScripts Strategies. You could follow the steps below to do so.
        • In the Control Center select Tools > Options.
        • Click the Strategies tab on the left-hand side.
        • On the right-hand side click the 'On connection loss' drop-down arrow.
        • Set 'Handling' to 'Keep Running'.
        • Set the 'Disconnect delay seconds' to a high enough value to be able to ride out brief disconnections so the strategy does not disable.
        • Click OK.
        Here is a Help Guide link for more information — https://ninjatrader.com/support/help...riptProperties
        Last edited by NinjaTrader_BrandonH; 10-08-2023, 08:46 PM.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Thank you Brandon for these inputs and clarifications!. It's great to have all these concepts in one place!
          Although I have work to do to tackle of these requirements my main concern is for now the use of OnExecutionUpdate()​ with CQG and Rithmic to handle partial fills.
          If I use the "(Rithmic/Interactive Brokers Friendly Approach)"​ to calculate Average Entry Price will the code of https://ninjatrader.com/support/help...tionupdate.htm work also for CQG ? So I'll have one code for all.
          A concern is also multithreading.
          To your knowledge is there a thread in the forum that offers a good example code to handle partial fills?
          Will StopTargetHandling.PerEntryExecution work with CQG and Rithmic ?
          Best
          G
          Last edited by giogio1; 10-09-2023, 03:38 AM.

          Comment


            #6
            Hello G,

            Thanks for your notes.

            Yes, you could calculate the average entry price in the script and use it on CQG or Rithmic.

            Here is a reference sample demonstrating the use of OnExecutionUpdate() and OnOrderUpdate(): https://ninjatrader.com/support/help...and_onexec.htm

            Attached you could find reference samples called ManagedRithmicIBFriendlyExamples_NT8 to view.

            Some Unmanaged Approach example script could be found on the forum threads below.

            https://forum.ninjatrader.com/forum/...roach-examples
            https://ninjatrader.com/support/foru...58#post1087458

            From the StopTargetHandling help guide page linked in my previous post: "If your strategy executes to an Interactive Brokers or TD Ameritrade account, the StopTargetHandling will always be forced to .ByStrategyPosition"

            Otherwise, yes, you could use whichever StopTargetHandling setting suits your overall goal.

            Review this help guide page for information about multi-threading considerations for NinjaScript: https://ninjatrader.com/support/help...-threading.htm
            Attached Files
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_BrandonH View Post
              This link appears to be broken.

              Comment


                #8
                Hello IanS00,

                Thanks for your notes.

                I have fixed the link in post # 2 and you could also find the link below.

                Unmanaged Approach: https://ninjatrader.com/support/help...d_approach.htm
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  This is very useful, thank you Brandon. I now have two paths to go for. One is starting from the unmanaged example (1) you provided and the other for the Rithmic Friendly (2).

                  Going for (1) unmanged, the year 2020 thread
                  good day together, i have now spent 2 days on this and other forums looking for a solution to my problem and hope to get an answer to my question here ;-) the following scenario in unmanaged mode: -----------------------------------------------------------------------------------------------------------------------------------

                  ends with "There is no need to work around order/execution/position ordering in connections that are not Interactive Brokers or Rithmic based"
                  Does it now work with Rithmic?
                  It appears that its most updated code is the UnmanagedTemplate_January2020.zip, correct?
                  Does this unmanagedTemplate handle the partial fills?
                  Does this unmanagedTemplate use an ATM for the oco so it woudn't backtest? That's probably ok.


                  If I go for the Rithmic Friendly example (2) i would start from the zip you provided:ManagedRithmicIBFriendlyExamples_NT8.zip (8.3 KB, 0 views)
                  and I would use ManagedRithmicIBFriendlyMultipleEntriesExample in it.
                  Does this handle the partial fills?
                  A note in its code says: ' Note: You need to calculate an entry's Average Fill Price from Executions '
                  I have the impression this example code has the the all AverageFillPrice implementation in it, correct?

                  Last, it appears that I must migrate complete away from Ninjatrader7 but I was also looking for an interim Rithmic compatible solution to save time. I wander if I must be compatible with Rithmic and willing to accept the limitated flexibility of the managed approach, would Nt7 work except the handling of the partial fills? For the time being I could monitor it closely.
                  Best.
                  G


                  Comment


                    #10
                    Hello G,

                    Thanks for your notes.

                    "There is no need to work around order/execution/position ordering in connections that are not Interactive Brokers or Rithmic based"

                    This means that if you are using a connection that is Rithmic-based, you must use the workaround for order/execution/position ordering that is seen in the OnExecutionUpdate(), OnOrderUpdate(), and OnPositionUpdate() help guide documentation.

                    Yes, the UnmanagedTemplate reference sample is the up-to-date version showing how Unmanaged Approach could be used. Note that this is not the Rithmic/IB friendly reference sample.

                    Attached you will find UnmanagedRithmicIBFriendly example scripts that you may view.

                    Yes, the ManagedRithmicIBFriendlyExample scripts and UnmanagedRithmicIBFriendlyExample scripts track the average fill price and uses OCO.

                    Please review the code of the reference samples to see exactly how the logic of the sample scripts function.

                    NinjaTrader 7 has OnExecution(), OnOrderUpdate(), and OnPositionUpdate() methods. You could create a NinjaTrader 7 strategy that implements similar logic to NinjaTrader 8 but you would need to take into account any code-breaking changes between platforms. Note that we do not have Rithmic/IB friendly reference samples for NinjaTrader 7.

                    You could find Code-breaking Changes on this help guide page: https://ninjatrader.com/support/help...ng_changes.htm
                    Attached Files
                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #11
                      You provided so many useful information. Thank you Brandon.

                      Continuing the conversation using ATM based strategy. If I write a code that uses an ATM, it appears that even with Rithmic I would get the compatibility and reliability I need the quickest way. Is that correct? How one should handle partial fills with a strategy that uses an ATM ?

                      Comment


                        #12
                        Hello G,

                        Thanks for your notes.

                        If you are referring to using an ATM Strategy Template in a custom NinjaScript strategy then you could use the Managed Approach with Atm Strategy Methods.

                        There are a few important notes that should be kept in mind when using ATM Strategy Templates in a custom NinjaScript. Please review this help guide page explaining this: https://ninjatrader.com/support/help...strategies.htm

                        See this help guide page detailing the available Atm Strategy Methods that could be used: https://ninjatrader.com/support/help...gy_methods.htm

                        You could view the SampleAtmStrategy script that comes default with NinjaTrader to see an example of using Atm Strategy Methods in NinjaScript. To view the script, open a New > NinjaScript Editor window, open the Strategies folder, and double-click on the SampleAtmStrategy file.
                        Brandon H.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by rhyminkevin, Today, 04:58 PM
                        4 responses
                        52 views
                        0 likes
                        Last Post dp8282
                        by dp8282
                         
                        Started by iceman2018, Today, 05:07 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post iceman2018  
                        Started by lightsun47, Today, 03:51 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post lightsun47  
                        Started by 00nevest, Today, 02:27 PM
                        1 response
                        14 views
                        0 likes
                        Last Post 00nevest  
                        Started by futtrader, 04-21-2024, 01:50 AM
                        4 responses
                        50 views
                        0 likes
                        Last Post futtrader  
                        Working...
                        X