Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

PositionAccount.Quantity not updated in OnExecutionUpdate()

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

    PositionAccount.Quantity not updated in OnExecutionUpdate()

    In my strategy, OnExecutionUpdate is called when there is an order execution. I check to make sure it is the correct order and is OrderState.Filled. The problem is the PositionAccount.Quantity is randomly SOMETIMES still zero at that time.

    The OnExecutionUpdate documentation says: "Executions drive the strategy Position object, which is updated when this method is called."

    This is a little vague. "When" means what? Before, during or after? Seems the Positions object should be updated before OnExecutionUpdate is called. So why is the quantity still zero sometimes?

    Thanks. ​

    #2
    Hello gbourque,

    The quote that you copied is intended for just the strategies position object which would be Position, the PositionAccount is not driven by the strategy, it is driven by the position update events on the account rather than the strategies OnExecutionUpdate event.

    It would generally be unexpected to be using the position inside OnExecutionUpdate to begin with as you can see the executions names to drive logic, is there some specific reason the position is needed in that area?

    Comment


      #3
      Yes, because in OnExecutionUpdate I create my stop/target(s). And I don't want to create those orders if there is no actual position. I know the quantity because I'm keeping track of it myself, but I just want to verify that the position actually exists before I create the stop/target(s).

      Comment


        #4
        However, I only need to know if the position actually exists if I add the bracket later at discretion. Since that call is not from OnEx, I can probably check the actual positions at that point. This might be a good workaround. I'll see.

        Comment


          #5
          Hello gbourque,

          Instead of placing the orders from OnExecutionUpdate() could you place the orders from OnPositionUpdate()?

          Or if these must be in OnExecutionUpdate() could you check the order being filled is an entry order?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            I'll check that out. Thanks!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            52 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            130 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            70 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            44 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            49 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X