Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Protected Override access without explicitly creating function

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

    Strategy Protected Override access without explicitly creating function

    I am trying to simplify the implementation of a tool to help develop strategies.

    There are a few override functions I currently have explicitly defined in the strategy such as: OnExecutionUpdate, OnOrderUpdate, and OnPositionUpdate

    I am trying to use the strategies Account information to subscribe to the events like this:
    Code:
    m_Strat.Account.OrderUpdate += OnOrderUpdate;
    m_Strat.Account.ExecutionUpdate += OnExecutionUpdate;
    
    Print("================>>>>>>> Delegates Subscribed "+m_Strat.Account.Name.ToString());
    m_Strat is assigned the "this" for the strategy of interest. I can see the subscription is done and m_Strat = "Playback101" which is correct. The only problem is this event doesn't seem to fire at all. When I use the override functions, the events are provided there, but I need to get them through this mechanism to make sure the overrides are not missed in a strategy and so those functions can be used by the parent strategy without being interfered with by the tool.

    Is there a different "Account" that gets these events within the strategy I need to use to get these to fire for strategies? The events need to be synchronized much like they came from the callbacks above (order, etc is important).

    #2
    Hello NJA_MC,

    You will first need to rename your event handler methods. OnOrderUpdate and OnExecutionUpdate have already been used by NinjaTrader, so you cannot use these names for your methods.

    Further, the account is only updated for real-time orders and not historical orders.

    I've created a test script and exported this so that you can test on your end.

    I am finding the account events run without issue.


    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Further, the account is only updated for real-time orders and not historical orders.
      Thanks Chelsea, I will play with that for real-time, I was only after the historical events at the moment. Is there a similar hook/delegate for historical based events much like what OnExecutionUpdate, OnOrderUpdate, and OnPositionUpdate capture? I can merge them if it is a different delegate for historical events.

      Comment


        #4
        Hello NJA_MC,

        Historical orders are not submitted live to a brokerage account.

        Historical orders will update OnOrderUpdate(), OnExectionUpdate(), and OnPositionUpdate() in a NinjaScript Strategy.


        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello NJA_MC,

          Historical orders are not submitted live to a brokerage account.

          Historical orders will update OnOrderUpdate(), OnExectionUpdate(), and OnPositionUpdate() in a NinjaScript Strategy.


          https://ninjatrader.com/support/help...tionupdate.htm
          Thanks Chelsea,

          Okay, since I need this historical data as well, it seems like I need to always add the override functions in the strategy... I will try to find a way to make sure they are added as the tool will not work properly if they are left out. I will have to abandon this approach to get this data.

          Comment


            #6
            Originally posted by NinjaTrader_ChelseaB View Post
            Hello NJA_MC,

            Historical orders are not submitted live to a brokerage account.

            Historical orders will update OnOrderUpdate(), OnExectionUpdate(), and OnPositionUpdate() in a NinjaScript Strategy.


            https://ninjatrader.com/support/help...tionupdate.htm
            Chelsea,

            If possible, I would like to open a request to have a delegate added as part of these functions so that they can be intercepted without the override. My use case is to pass a Strategy's "this" to another class and would like that class to be able to subscribe without impacting the original strategy. A simple naming might be to append "Delegate" to the override name.

            Eg:

            Code:
            m_Strat.OrderUpdateDelegate += OnOrderUpdateFunc;
            m_Strat.ExecutionUpdateDelegate += OnExecutionUpdateFunc;

            Comment


              #7
              Hello NJA_MC,

              What is the specific use case where it is not sufficient to call your custom class method from OnOrderUpdate or OnExecutionUpdate?

              May we have an export of an example?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_ChelseaB View Post
                Hello NJA_MC,

                What is the specific use case where it is not sufficient to call your custom class method from OnOrderUpdate or OnExecutionUpdate?

                May we have an export of an example?
                Hi Chelsea,

                I am working on releasing a new product as a NinjaTrader Partner which is called LOM (Local Order Manager). This tool will wrap the NinjaTrader Unmanaged Orders to provide many powerful trading setups/adjustments etc for strategies. For example, entering a trade can automatically place protective SL & PT if desired. Other features include bracket orders, Trailing stop, Break Even, etc with more to come.

                My desire to to reduce the complexity of the needed code in the strategy such that LOM users don't need to remember to include the overrides or figure out how to include the required LOM overrides in combination with what they have created themselves. LOM (recommended by NT) has become an Indicator which will manage orders & positions for strategies. I need to capture all order updates, etc for both historical (back testing) and real-time trades to make sure the Unmanaged orders remain in sync.

                I am hoping to get a LOM initial release version into QC for testing and release as a new partner. I can probably do it with the OnXXXXX functions, but my concern is if these are accidently left off from a strategy (users need to add this manual) then it can cause major headaches for the user. Having the Delegate would allow me to eliminate this critical step for proper operation of the tool eliminating frustration and heart ache!

                EDIT: I have attached an example with Auto SL, BreakEven & Trailing stop so you know what I am talking about.
                Last edited by NJA_MC; 01-05-2021, 09:23 PM. Reason: Adding "LOMTEST.cs" as example

                Comment


                  #9
                  Here is the sample LOMTEST.cs file as a reference.
                  Attached Files

                  Comment


                    #10
                    Hello NJA_MC,

                    I've submitted your request for consideration.

                    Once I have a tracking ID for this request I will post this for future reference.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello NJA_MC,

                      This request is being tracked with ID# SFT-5174.

                      As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

                      Release Notes — https://ninjatrader.com/support/help...ease_notes.htm
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Add my vote to this feature

                        Comment


                          #13
                          Hello wzgy0920,

                          Thank you for your vote.

                          I've added this to SFT-5174.
                          Chelsea B.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by NullPointStrategies, Today, 05:17 AM
                          0 responses
                          50 views
                          0 likes
                          Last Post NullPointStrategies  
                          Started by argusthome, 03-08-2026, 10:06 AM
                          0 responses
                          126 views
                          0 likes
                          Last Post argusthome  
                          Started by NabilKhattabi, 03-06-2026, 11:18 AM
                          0 responses
                          69 views
                          0 likes
                          Last Post NabilKhattabi  
                          Started by Deep42, 03-06-2026, 12:28 AM
                          0 responses
                          42 views
                          0 likes
                          Last Post Deep42
                          by Deep42
                           
                          Started by TheRealMorford, 03-05-2026, 06:15 PM
                          0 responses
                          46 views
                          0 likes
                          Last Post TheRealMorford  
                          Working...
                          X