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

Partial fills - Modified SampleOnOrderUpdate

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

    Partial fills - Modified SampleOnOrderUpdate


    NinjaTrader_Jim,

    Thank you for posting your modified SampleOnOrderUpdate for partial fills (attached) (https://ninjatrader.com/support/foru...58#post1087458).

    I believe I've wrapped my head around your logic. Though, should you have time, more in-code comments would be appreciated.
    Differencing your modified code with the original SampleOnOrderUpdate shows in OnBarUpdate() the addition of "if (State == State.Historical) return;" and "Position.MarketPosition == MarketPosition.Flat".
    Please explain your logic in adding "Position.MarketPosition == MarketPosition.Flat".
    Again, thank you for posting the code.

    Regards
    Shannon
    Attached Files

    #2
    Hello Shansen,

    Thanks for your question.

    if (State == State.Historical) return; is used to skip historical processing so realtime order submissions can be tested easily.

    The check for the flat position is consistent with the current example. We are simply checking if the strategy is in a flat position before submitting the entry order.

    The in house example for SampleOnOrderUpdate which that Rithmic modification was derived can be found here - https://ninjatrader.com/support/help...and_onexec.htm

    The biggest item to note with the modified example for Rithmic is that we check if there has been a partial fill, and if there was, we want to make sure we update the target/stop if the last update we see was an Order event as opposed to an Execution event.

    I look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3

      Apologies. The SampleOnOrderUpdate I used was from several years ago. Thanks for the clarification.

      Differencing the SampleOnOrderUpdate(2019) and your modified SampleOnOrderUpdate, has helped. I now understand both files handle partial fills.

      Please confirm your modified SampleOnOrderUpdate is only required where a broker's API adapter does not guarantee the sequence of events of OnOrderUpdate, OnExecution, and OnPositionUpdate (i.e. Rithmic and Interactive Brokers) (https://ninjatrader.com/support/foru...34#post1087234).

      Please confirm the original SampleOnOrderUpdate(2019) is sufficient where a user's broker is NinjaTrader Brokerage.
      Last edited by Shansen; 04-30-2020, 04:08 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mongo, Today, 11:05 AM
      2 responses
      7 views
      0 likes
      Last Post Mongo
      by Mongo
       
      Started by guillembm, Today, 11:25 AM
      0 responses
      3 views
      0 likes
      Last Post guillembm  
      Started by Tim-c, Today, 10:58 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by traderqz, Yesterday, 09:06 AM
      4 responses
      27 views
      0 likes
      Last Post traderqz  
      Started by traderqz, Today, 12:06 AM
      5 responses
      8 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X