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

Market position not uptodate after order filled

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

    Market position not uptodate after order filled

    Hi,

    I see that in rare occasions the market position of the strategy is not uptodate. For example, what that I see is that the order has been filled on tick #1000 (I check that during Onorderupdate) but the market position is updated 10 ticks later (tick #1010). Is there way to get the position to be updated when the order is filled?

    Thanks!

    Juan


    #2
    Hello Aquatrade,

    Thank you for your reply.

    Who is your data provider?

    You could certainly use the unmanaged approach and calculate the position internally to the strategy. The strategy could then rely on it's own calculated position in lieu of relying on position updates from the broker. I've attached an example of this below.

    An overview of using the unmanaged approach may be found in our help guide here:



    Please let us know if we may be of further assistance to you.
    Attached Files
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thanks,

      My data provider is CQG. The example is very useful, I'll try to use some of the ideas in your code for my strategy.

      Thanks one more time

      Juan

      Comment


        #4
        I have an additional question. In the code you provide I see:
        Code:
        if (shortEntry != null && shortEntry == order)
        {
        // Reset the shortEntry Order object to null if order was cancelled without any fill
        if (order.OrderState == OrderState.Cancelled && order.Filled == 0)
        {
        shortEntry = null;
        }
        }
        what is the difference between:

        order.OrderState == OrderState.Cancelled && order.Filled == 0

        and

        order.OrderState == OrderState.Cancelled


        In other words, why checking for number of orders filled? is it because of partial fill?

        Thanks!

        Comment


          #5
          Hello Aquatrade,

          Thank you for your reply.

          Yes, that's exactly right, because if the order is partially filled but not fully filled we would want to handle that differently than simply just setting that reference back to null immediately.

          Please let us know if we may be of further assistance to you.
          Kate W.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by cre8able, Today, 03:20 PM
          1 response
          9 views
          0 likes
          Last Post cre8able  
          Started by fiddich, Today, 05:25 PM
          0 responses
          3 views
          0 likes
          Last Post fiddich
          by fiddich
           
          Started by gemify, 11-11-2022, 11:52 AM
          6 responses
          804 views
          2 likes
          Last Post ultls
          by ultls
           
          Started by ScottWalsh, Today, 04:52 PM
          0 responses
          4 views
          0 likes
          Last Post ScottWalsh  
          Started by ScottWalsh, Today, 04:29 PM
          0 responses
          9 views
          0 likes
          Last Post ScottWalsh  
          Working...
          X