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

Strategy.Position delay in updating?

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

    Strategy.Position delay in updating?

    I am writing an unmanaged order handler and part of its job is to place a stop loss as soon as the entry order is filled.

    My order of operations are:
    1. SubmitOrderUnmanaged(....my entry order....)
    2. OnOrderUpdate is called with OrderState.Filled
    3. Immediately look to place stoploss by looking at Position.MarketPosition


    The problem is that Position.MarketPosition is returning MarketPosition.Flat and thus the stop is not being placed immediately. Is there any delay in the Strategy.Position being updated? I can simply look at the order itself but wondering why this field is not updated as I rely on it in several other places.

    #2
    Putting some debug code together shows that the Position still shows Flat until the next incoming tick....would it not be ideal to update the strategy position before NT calls the onorderupdate with a fill? Perhaps there is some other reason as to why it is not this way.

    Comment


      #3
      Hello FxRichard,

      Thank you for your note.

      Within OnOrderUpdate section of the helpguide you’ll see,

      Critical: If you want to drive your strategy logic based on order fills you must use OnExecutionUpdate() instead of OnOrderUpdate(). OnExecutionUpdate() is always triggered after OnOrderUpdate(). There is internal strategy logic that is triggered after OnOrderUpdate() is called but before OnExecutionUpdate() that can adversely affect your strategy if you are relying on tracking fills within OnOrderUpdate().

      https://ninjatrader.com/support/help...rderupdate.htm

      Its suggested you use OnPositionUpdate(),
      https://ninjatrader.com/support/help...tionupdate.htm

      I have attached a sample strategy which if you apply to a 10 second chart and pull up an output window, you’ll see that while OnOrderUpdate prints flat OnOrderExecution/OnPositionUpdate will print a position reflecting the most recent fill.

      Please let us know if you need further assistance.
      Attached Files
      Alan P.NinjaTrader Customer Service

      Comment


        #4
        Thanks Alan, somehow missed that info.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jasinhbca, Today, 01:20 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_ChristopherS  
        Started by jhjhawkins, Today, 12:25 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by rexsole, Today, 11:48 AM
        1 response
        16 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Started by jeronymite, Yesterday, 05:05 PM
        3 responses
        56 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by Don22Trader1, Yesterday, 05:54 PM
        3 responses
        50 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X