• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit Positions from Unmanaged Orders

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

    Exit Positions from Unmanaged Orders

    Hi All,

    I have been focusing on strategies using unmanaged orders, so far I can successfully submit and create TP's and SL's via OnOrderUpdate. So far so good.

    However I would like to know how to swap an order when the conditions are reversed. So for instance a moving average crossover.

    The managed approach does it for me and can only have 1 direction per trade.

    So how would I exit an unmanaged position? for example I have

    Code:
    if (Position.MarketPosition == MarketPosition.Flat && longLimitEntry == null)
    {
    longLimitEntry = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Limit, OrderQuantity, Low[0] - (10 * TickSize)), 0, ocoString, "longLimitEntry");
    }


    is it as simple as submitting another "SubmitOrderUnmanaged for OrderAction.Sell, OrderType.Market"?

    Thanks for your help.
    Last edited by mr_trade; 08-20-2019, 01:04 PM.

    #2
    Hello mr_trade,

    Thanks for your post.

    When working with Unmanaged strategies, we are only thinking in terms of buying and selling.

    You could check Position.MarketPosition == MarketPosition.Long and then do as you suggest to use SubmitOrderUnmanaged for OrderAction.Sell, OrderType.Market for the quantity Position.Quantity.

    Reversing then would involve submitting an order with a greater order quantity which would but the strategy in a short position rather than a flat position.

    Please let me know if I can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks for your quick reply. As you say it makes sense for the opposite signal to simple double the original position to switch sounds easier

      thanks will I’ll have a go later.

      Comment


        #4
        Hi Jim,

        I have tried doing the above, but in backtesting I just get 2 orders now one buy one sell. Even doubling up I just get double the original entry on my new order.

        Do I need to link the orders to their unique order entry number somehow?

        Thanks for your help.

        Regards

        Comment


          #5
          Hi Jim,

          Ignore me, I just realised I didn't have BuyToCover on. Thanks! Its working now.

          Thanks for your guidance.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Fastbyte, Yesterday, 11:13 PM
          1 response
          1 view
          0 likes
          Last Post NinjaTrader_ChrisSch  
          Started by StealthM93, Yesterday, 07:58 PM
          1 response
          7 views
          0 likes
          Last Post bltdavid  
          Started by Mykro, Yesterday, 11:01 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by bauerjj10, Yesterday, 12:24 PM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Newtrader101, Yesterday, 06:01 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_EricB  
          Working...
          X