• 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 UltraNIX, Today, 12:31 AM
          1 response
          7 views
          0 likes
          Last Post NT-Roland  
          Started by hedgeplay, Yesterday, 08:04 PM
          0 responses
          4 views
          0 likes
          Last Post hedgeplay  
          Started by DTSSTS, Yesterday, 07:02 PM
          0 responses
          6 views
          0 likes
          Last Post DTSSTS
          by DTSSTS
           
          Started by arguru, Yesterday, 04:07 PM
          1 response
          15 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by lakersfan, Yesterday, 06:02 PM
          0 responses
          14 views
          0 likes
          Last Post lakersfan  
          Working...
          X