Announcement

Collapse
No announcement yet.

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().



      Its suggested you use OnPositionUpdate(),


      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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        46 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        31 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        50 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        42 views
        0 likes
        Last Post CarlTrading  
        Working...
        X