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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    59 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    143 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    161 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    97 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    283 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X