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 kujista, Today, 06:23 AM
          0 responses
          1 view
          0 likes
          Last Post kujista
          by kujista
           
          Started by traderqz, Yesterday, 04:32 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by f.saeidi, Today, 05:56 AM
          1 response
          4 views
          0 likes
          Last Post Jltarrau  
          Started by Jltarrau, Today, 05:57 AM
          0 responses
          4 views
          0 likes
          Last Post Jltarrau  
          Started by Stanfillirenfro, Yesterday, 09:19 AM
          7 responses
          52 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X