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

  • fxRichard
    replied
    Thanks Alan, somehow missed that info.

    Leave a comment:


  • NinjaTrader_AlanP
    replied
    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

    Leave a comment:


  • fxRichard
    replied
    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.

    Leave a comment:


  • fxRichard
    started a topic Strategy.Position delay in updating?

    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.

Latest Posts

Collapse

Topics Statistics Last Post
Started by dasynark, Today, 11:34 PM
0 responses
1 view
0 likes
Last Post dasynark  
Started by dasynark, Today, 11:31 PM
0 responses
0 views
0 likes
Last Post dasynark  
Started by AddisonTremb, Today, 10:52 PM
0 responses
5 views
0 likes
Last Post AddisonTremb  
Started by a5435754, Today, 10:35 PM
0 responses
6 views
0 likes
Last Post a5435754  
Started by JanickEichman, Today, 10:32 PM
0 responses
2 views
0 likes
Last Post JanickEichman  
Working...
X