Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnPositionUpdate & OnOrderUpdate

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

    OnPositionUpdate & OnOrderUpdate

    Hi,

    I have a question with regards to the following;

    OnPositionUpdate(IPosition position)

    Code:
    if (position.MarketPosition == MarketPosition.Long) priorTrade = position.AvgPrice;
    OnOrderUpdate(IOrder order)
    Code:
    if (order.OrderState == OrderState.Filled) priorEntry = order.AvgFillPrice;
    After using both of the above types I want to confirm the output when using Print...is it normal for both of them to continually print 0 to the output screen when their is no position?

    The code runs as expected but because I haven't done this before I was hoping for some feedback. I'd also like to ask is their any benefit to using one over the other or are they essentially the same?

    Regards,
    suprsnipes

    #2
    Hello,

    The differences between them are detailed at the top of each of these links:



    Note that they are only called when there is an event, so they will do nothing (will not be called) when there is no change in state.
    DenNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cmoran13, Yesterday, 01:02 PM
    0 responses
    30 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    22 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    160 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    95 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    148 views
    2 likes
    Last Post CaptainJack  
    Working...
    X