Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Advice needed on canceling system generated order

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

    Advice needed on canceling system generated order

    I have a strategy that places limit entry orders and market exit orders. I had a situation where current position is Long, and the strategy generated a Short limit order. NT automatically generated a "Close position" exit order along with the Short limit entry order, which I believe is expected. Then, the strategy exited the Long position with a market order. The 2 short orders remain, however only the one generated by the strategy is needed. The system generated "Close position" generates an entry with a name that my strategy does not recognize and cannot manage.

    Is it possible to find these leftover "Close position" orders programmatically to be able to cancel them?

    Thanks,
    Tim

    #2
    Hello Nailz420,

    Thank you for your note.

    Correct, it is expected to have an additional order placed for closing the position and then submitting an order to the opposite direction. This is true for the Managed approach and using Enter() orders.

    Additionally, the Close position orders are going to be market orders and there shouldn't be any left over from the strategy. Is that what you are seeing with the Orders Tab?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      1. I see a limit Close position order along with my limit entry order with the same amount and price and I think it's correct behaviour. Are you saying that even for a limit entry order the system should enter a market close position order at the exact moment the limit price is reached not as a limit order?

      2. I used this code to cancel the leftover close position order:
      Code:
      if(Position.MarketPosition==MarketPosition.Flat){
      	foreach(Order o in Orders){
      		if(
      			(o.OrderState==OrderState.Working && o.Name=="Close position")
      		){
      			o.Cancel();
      		}
      	}
      }
      Thanks,
      Tim

      Comment


        #4
        Tim,

        Correct, it will be a Limit order for the opposite position.

        The method you supplied should work in theory, but not tested.
        Have you tried it on your end? It would be worth a shot
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Testing it now with market replay and it seems to be working. No idea if the results will be the same with sim or live.

          Tim.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          2 views
          0 likes
          Last Post Javierw.ok  
          Started by timmbbo, Today, 08:59 AM
          2 responses
          10 views
          0 likes
          Last Post bltdavid  
          Started by alifarahani, Today, 09:40 AM
          6 responses
          40 views
          0 likes
          Last Post alifarahani  
          Started by Waxavi, Today, 02:10 AM
          1 response
          18 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by Kaledus, Today, 01:29 PM
          5 responses
          15 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X