Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limiting position size as opposed to entries per direction

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

    Limiting position size as opposed to entries per direction

    Hello all,

    Is there a way to have NT ignore orders that add to a position once a certain position size has been reached?

    I'm using my own logic to fill partially filled orders that involves canceling existing partially filled orders and entering new orders for the balance of the unfilled position. I believe this prevents me from limiting the position size via the EntriesPerDirection property. i.e. If I limit my EntriesPerDirection to 1 (which, in theory, is fine because I never want to pyramid in my strategy), but my desired position size is 6 contracts and I only get filled on 4, how do I add the other 2 contracts after I've already cancelled the open partially-filled order?

    What I'm trying to avoid is some undiscovered bug in my logic putting me into many more contracts than I'd like. Any suggestions are greatly appreciated.

    Ken

    #2
    You can check the strategy position's size (Position.Quantity) but due to the timing of it's updates you would need to check directly with the IOrder's what size is filled for your entry (.Filled) so you can rectify mismatches then and issue another order on cancelling the PartFilled one. Just be sure to wait for orderstate change confirmations to not 'produce' overfill scenarios.

    Comment


      #3
      If a CancelOrder() is issued on an IOrder that has already been filled, will the status change to .Cancelled? Meaning if I always cancel the current order before issuing a new order can I just check for OrderState == Orderstate.Cancelled?
      Last edited by kaydgee; 09-15-2010, 10:28 AM. Reason: Pressed "submit" too fast

      Comment


        #4
        No, it would have a filled orderstate then, as the cancel request was never confirmed by the broker then (otherwise it would have changed and reported back to you).

        Comment


          #5
          So, if I'm issuing all of my orders in the OnMarketData() method, and I'm recycling the same variable (entryOrder) to hold the IOrder, can I just check that entryOrder.OrderState != .Cancelled, .Filled, .Rejected, or .Unknown, and then issue a CancelOrder(entryOrder) before issuing a new order?

          Or, would it be better to check entryOrder in OnOrderUpdate() and if entryOrder.OrderState == .Cancelled, .Filled, .Rejected, reset entryOrder = null and check for that condition before issuing new orders in OnMarketData()?

          Comment


            #6
            Hi Kay, OnOrderUpdate() would be the place to check, since it will be the first to have the orderstate changes reported to.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            574 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X