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

OnOrderUpdate() or OnExecutionUpdate() is never called

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

    OnOrderUpdate() or OnExecutionUpdate() is never called

    Hi, NT support,

    I am using OnBarUpdate() to submit an order as follows. I am using simulated data feed. Do I miss anything here as I cannot let OnOrderUpdated() be called?
    ...
    protected override void OnBarUpdate()
    {...

    Print("this is called printed successfully");
    EnterLong("Test 1");
    ..


    Then the following Print() is never called.

    protected override void OnOrderUpdate(...)
    {
    Print("This is never called");
    ...
    }


    Thanks.

    #2
    Hello localappleseed,

    Thanks for your post.

    Here is what I see when connected to a live data feed and looking at historical orders on a 1-minute chart of NQ 09-20. Both OnorderUpdate() and OnExecutionUpdate() are called.

    Click image for larger version

Name:	localappleseed-1.PNG
Views:	471
Size:	102.6 KB
ID:	1117348

    Are you able to replicate this example?
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi, Paul,

      Thanks for providing the sample code. I tried your code but still not work. Are you use simulated data feed?

      Here is what I got from the output:

      Strategy 'L2CustomStrategy/210086296': An order placed at '9/8/2020 11:00:00 AM' has been ignored since the order was submitted before the strategy property BarsRequiredToTrade had been met.

      Enabling NinjaScript strategy 'L2CustomStrategy/210086296' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes


      Comment


        #4
        Hello localappleseed,

        Thanks for your post.

        Yes, I connected to the connection labeled, "Simulated data feed".

        I also connected to a live data feed, the results are the same.

        The ignored order message would be expected and would not prevent the strategy from running or producing the results I have shown.

        The "enabling..." message is also expected.

        Please check the "log" tab of the control center and advise if there are other errors (besides the ignored order).

        Otherwise, please attach your strategy code file to your post. The file can be found in Documents>Ninjatrader8>bin>Custom>Strategies> and will be of a .cs type.\ and will be named L2CustomStrategy.

        Also, please provide the sequence of steps to recreate.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hi, Paul,

          Actually I got data printed which means they are called, it just takes longer time than I expected. Thanks again.

          Comment


            #6
            Hi, Paul,

            I have further related question here.
            I tried charts of different time such as 5 sec, 1 min etc. I noticed OnExecutionUpdate() can be called only once while OnOrderUpdate() is called 4 times. Is this expected and why? Thanks.

            Comment


              #7
              Originally posted by localappleseed View Post
              Hi, Paul,

              I have further related question here.
              I tried charts of different time such as 5 sec, 1 min etc. I noticed OnExecutionUpdate() can be called only once while OnOrderUpdate() is called 4 times. Is this expected and why? Thanks.
              Yes, it is expected.

              An Order object goes through several states,
              which you can observe by printing OrderState.

              Comment


                #8
                Hello localappleseed,

                Thanks for your post.

                As member bltdavid advised this would be expected.

                The order would be executed once and then go through a few order states, please see: https://ninjatrader.com/support/help...efinitions.htm

                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Hi, Paul or any supporters,

                  Could you please help me for additional questions here?
                  1) I use the same sample code to submit order using EnterLong(), this EnterLong() is called many times, doesn't this mean many buy orders have been submitted? I only see occasionally OnExecutionUpdate() is called which means most buy orders are not executed, why?

                  2) When I submit an order using EnterLongLimit(GetCurrentBid()+0.1), which means I bid with higher price, but still it takes many orders to get one order executed, how do I increase the chance to let order executed reliably?

                  Thanks.

                  Comment


                    #10
                    Hello localappleseed,

                    Thanks for your reply.

                    The strategy parameter EntriesPerDirection will prevent orders from being executed if you have exceeded that parameter.

                    Reference: https://ninjatrader.com/support/help...tegyProperties
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      Cool! Thanks

                      Comment


                        #12
                        My order from EnterLong() has been ignored, see below:
                        Strategy 'XXXX/210086305': An order placed at '9/9/2020 5:57:06 PM' has been ignored since the order was submitted before the strategy property BarsRequiredToTrade had been met.

                        I cannot check order status through OnOrderUpdate() either because of the order is ignored.

                        How to resolve this? Is there a way to check if Strategy Property BarsRequiredToTrade is ready, so order submitted can be executed?
                        Thank you in advance.
                        Last edited by localappleseed; 09-09-2020, 04:31 PM.

                        Comment


                          #13
                          I am all set for the above questions. The following code does it.
                          if (CurrentBars[0] < BarsRequiredToTrade || CurrentBars[1] < BarsRequiredToTrade)
                          return;

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Perr0Grande, Today, 08:16 PM
                          0 responses
                          2 views
                          0 likes
                          Last Post Perr0Grande  
                          Started by elderan, Today, 08:03 PM
                          0 responses
                          4 views
                          0 likes
                          Last Post elderan
                          by elderan
                           
                          Started by algospoke, Today, 06:40 PM
                          0 responses
                          10 views
                          0 likes
                          Last Post algospoke  
                          Started by maybeimnotrader, Today, 05:46 PM
                          0 responses
                          11 views
                          0 likes
                          Last Post maybeimnotrader  
                          Started by quantismo, Today, 05:13 PM
                          0 responses
                          7 views
                          0 likes
                          Last Post quantismo  
                          Working...
                          X