Announcement

Collapse
No announcement yet.

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.​
    <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


      #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.
          <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


            #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
              <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

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              56 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              133 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              73 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              49 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X