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

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, [COLOR=#252C2F]Low[0] - (10 * TickSize)),[/COLOR] 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 DJ888, Today, 10:57 PM
          0 responses
          6 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          158 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Today, 09:29 PM
          0 responses
          7 views
          0 likes
          Last Post Belfortbucks  
          Started by zstheorist, Today, 07:52 PM
          0 responses
          7 views
          0 likes
          Last Post zstheorist  
          Started by pmachiraju, 11-01-2023, 04:46 AM
          8 responses
          151 views
          0 likes
          Last Post rehmans
          by rehmans
           
          Working...
          X