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() not called when using EntryLongStopMarket()

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

    OnOrderUpdate() not called when using EntryLongStopMarket()

    Hi,

    I'm setting up a strategy where need to use a stop order to enter a trade long or short. For some reason when this function is executed, OnOrderUpdate() is not called. Is this expected?

    The command I have is:
    Code:
    EnterLongStopMarket(0, true, 1, _stop, "Enter Long");

    #2
    Hello Magzor,

    Thanks for your post.

    The frequency that OnOrderUpdate() is called is dependent on the Calculate mode that is used.

    Calculate.OnBarClose allows the strategy to process OnBarUpdate() logic at the close of each bar. Calculate.OnPriceChange allows the strategy to process OnBarUpdate() logic for each change in price. Calculate.OnEachTick allows the strategy to process OnBarUpdate() logic for each incoming tick that occurs.

    See this help guide for more information about Calculate: https://ninjatrader.com/support/help.../calculate.htm

    You could confirm that OnBarUpdate() logic is being fired by adding prints to the script. Prints will appear in a New > NinjaScript Editor window.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.

    https://ninjatrader.com/support/foru...121#post791121

    Let us know if we may assist further.​
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hi Brandon,

      Thank you for the reply
      I am using Calculate.OnBarClose

      The reason I'm confused is that if I use
      Code:
      EnterLong("Enter Long");
      then OnOrderUpdate is called... Any idea what that could be?

      Comment


        #4
        Originally posted by NinjaTrader_BrandonH View Post
        The frequency that OnOrderUpdate() is called is dependent on the Calculate mode that is used.

        Calculate.OnBarClose allows the strategy to process OnBarUpdate() logic at the close of each bar. Calculate.OnPriceChange allows the strategy to process OnBarUpdate() logic for each change in price. Calculate.OnEachTick allows the strategy to process OnBarUpdate() logic for each incoming tick that occurs.

        You could confirm that OnBarUpdate() logic is being fired by adding prints to the script. Prints will appear in a New > NinjaScript Editor window.
        Come on, Brandon!

        Your answer is inconsistent and shows a complete
        lack of understanding of the original question.

        The OP is asking about OnOrderUpdate.

        He is not asking about OnBarUpdate.

        So, why are you talking about OnBarUpdate?
        Did you not read his post?

        -=o=-

        OnOrderUpdate and OnBarUpdate are completely independent of one another.

        The Calculate setting has nothing to do with OnOrderUpdate.

        Comment


          #5
          Hello Magzor,

          Thanks for your note.

          My apologies, I had accidentally read the initial inquiry as OnBarUpdate(), not OnOrderUpdate().

          OnOrderUpdate() will be called each time an order changes state. If the order has not changed states then OnOrderUpdate() will not be fired.

          An example of an order changing states would be if the order goes from OrderState.Working to OrderState.Filled when the order is filled.

          The first section of sample code in the OnOrderUpdate() help guide page linked below could be used to print out the most current order state of an order object and print out the particular order update state. This help guide page also demonstrates how you could track an order object in OnOrderUpdate().

          OnOrderUpdate(): https://ninjatrader.com/support/help...rderupdate.htm

          OnExecutionUpdate() could also be used to get information about an order object when the order object is filled.

          See this reference sample that demonstrates how OnOrderUpdate() and OnExecutionUpdate() could be used: https://ninjatrader.com/support/help...and_onexec.htm

          Please let me know if you have further questions.
          Brandon H.NinjaTrader Customer Service

          Comment


            #6
            Hi Brandon, thanks for the reply.

            Let me ask it a bit more specific. Is it expected that OnOrderUpdate is not called when executing this line of code?

            EnterLongStopMarket(0, true, 1, _stop, "Enter Long");

            Just trying to figure whats happening here. I assume it should at least trigger the initialized state

            Comment


              #7
              Hello Magzor,

              Thanks for your note.

              Yes, when EnterLongStopMarket() is triggered and submits an order the OnOrderUpdate() method will fire.

              See the attached screenshot demonstrating this. In the screenshot, we can see that when EnterLongStopMarket() submits an order and we also see prints from the OnOrderUpdate() method appear in a NinjaScript Output window. We see two print outputs from OnOrderUpdate(), one showing when the order reaches an OrderState of Submitted and a second print showing when the order changes states from Submitted to Accepted.

              I have also attached the strategy used to test this to my reply so you could view it and test it on your end.

              Please let me know if you have further questions.
              Attached Files
              Brandon H.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jxs_xrj, 01-12-2020, 09:49 AM
              6 responses
              3,290 views
              1 like
              Last Post jgualdronc  
              Started by Touch-Ups, Today, 10:36 AM
              0 responses
              7 views
              0 likes
              Last Post Touch-Ups  
              Started by geddyisodin, 04-25-2024, 05:20 AM
              8 responses
              61 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by Option Whisperer, Today, 09:55 AM
              0 responses
              8 views
              0 likes
              Last Post Option Whisperer  
              Started by halgo_boulder, 04-20-2024, 08:44 AM
              2 responses
              24 views
              0 likes
              Last Post halgo_boulder  
              Working...
              X