Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with Unmanaged Exits

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

    Help with Unmanaged Exits

    Hello,
    I'm new to this Unmanaged Approach and I'm missing something. The SubmitOrders that I intend as exits are being disregarded and at times actually entering as new trades. The only time my entries are exiting is when an opposite entry fires. Can someone please point out my error. I would be incredibly grateful. Here is one side of my code. The other side is simply opposite.

    Code:
    private IOrder BullQuickI = null;
    private IOrder BullRunnerI = null;
    //Entry Conditions for Bull
                if (CrossBelow(MACD(12, 26, 9).Avg, MACD(12, 26, 9), 1)
                    && BullQuickI == null
                    && BullRunnerI == null)
                {
                    BullQuickI = SubmitOrder(0, OrderAction.Buy, OrderType.Market, 1, 0, 0, "", "BullQuickI");
                        Print(Time[0] + " Enter BullQuick I - " + BullQuickI.OrderId);
                    BullRunnerI = SubmitOrder(0, OrderAction.Buy, OrderType.Market, 1, 0, 0, "", "BullRunnerI");
                        Print(Time[0] + " Enter BullRunner I - " + BullRunnerI.OrderId);
                    m_inBullQuickMove = true;
                    m_inBullRunner = true;
                }
                        //Conditions to Exit BullQuickI         
                            if (Close[0] > Position.AvgPrice
                                && m_inBullQuickMove 
                                && Falling(RMI(10, 3)) == true)
                               {
                                    BullQuickIExit = SubmitOrder(0, OrderAction.SellShort, OrderType.Market, 1, 0, 0, "BullQuickI", "BullQuickIExit");
                                    m_inBullQuickMove = false;
                                    Print(Time[0] + " BullQuickIExit - " + BullQuickIExit.OrderId);
                                }
                        //Conditions to Exit BullRunnerI 
                            if (m_inBullRunner && Close[0] < VMAZones (9, 2, 18).Lower[0]
                                //&& BullRunnerExitOK
                                && TrendStrengthA(VC.NinjaScript.Utility.MovingAverageType.VWMA, 200, 20, 10).TrendStrength[0] < 60
                                && Falling(RMI(10, 3)) == true)
                                    {
                                        BullRunnerIExit = SubmitOrder(0, OrderAction.SellShort, OrderType.Market, 1, 0, 0, "BullRunnerI", "BullRunnerIExit");
                                        m_inBullRunner = false;
                                        BullRunnerExitOK = false;
                                        Print(Time[0] + " BullRunnerIExit - " + BullRunnerIExit.OrderId);
                                    }
    protected override void OnOrderUpdate(IOrder order)
        {
            if (BullQuickI != null && BullQuickI == order)
            {
                if (order.OrderState == OrderState.Filled || order.OrderState == OrderState.Cancelled)
                        BullQuickI = null;
            }
            if (BullRunnerI != null && BullRunnerI == order)
            {
                if (order.OrderState == OrderState.Filled || order.OrderState == OrderState.Cancelled)
                        BullRunnerI = null;
            }
    }

    #2
    CaptainAmericaXX, that can happen in the unmanaged approach - you're just submitting an order, it would not check if there is actually a position to exit from for example like in the managed approach. You would need to debug your code and understand where additional checks are needed to not submit an order that would actually enter a position for you that you do not intend at this time.

    Comment


      #3
      Bertrand thank you for the reply. I have placed in flags where I thought would create the appropriate checks and the exits that I created are still being disregarded. Let me try to explain. Let's say an order (BullQuickI && BullRunnerI) was filled in bar 25. The exit for BullQuickI should have been called (and is called perfectly with the managed approach) in bar 32. The BullRunnerI keeps going until bar 50 when it's exit is called. All that works fine with one side (say long side) in the managed approach. The problem comes when I add the short side to the equation. So back to the example, I now how 2 shorts that, if we could look into the future, are going to fire in bar 36 (after the BullQuickI should have fired). For some reason that I haven't been able to figure out, that BullQuickExit does not get filled in bar 32. Instead both the BullQuickI and BullRunnerI exit when in bar 36 the BearQuickI and BearRunnerI are called. Then in bar 50 when the original BullRunnerI should have exited, a BullRunnerIExit fires in a short position. Also, it's like that BullQuickIExit says, "Hey I should have fired in bar 32, but didn't, so I'm just going to jump in here." and I get another short.
      You said that the managed approach just submits orders. I can see that. What I can't see is why, when I add the short entries to the market my first exit (at bar 28 in the example) is being disregarded. It's like, with the Unmanaged Approach, it just became invisible. Can you please give me a reason this would happen?
      Last edited by CaptainAmericaXX; 08-11-2011, 06:05 AM.

      Comment


        #4
        CaptainAmericaXX, in the unmanaged mode there's no order tracking done, so meaning for example when Submit an order to exit and you would not have any position > it would bring you into the opposite position then. The same scenario in the managed mode would add a safeguard, so the exit order would be ignored as there's no position existing to exit from. Therefore those two modes needed to be treated independently in your analysis: were you seeing ignored orders in your managed mode trace order output?

        The internal order handling rules would be applied to the managed mode, but not to the unmanaged one :

        Comment


          #5
          I believe I figure out why some exits were being ignored. One of my indicators for exits needed a certain amount of bars to build. When that exit wasn't working properly it seemed to throw off the following entries and exits and just seemed to snowball after that.
          The main issue is that my expectations of the Unmanaged Approach seemed to be false. I thought that in Unmanaged I could have shorts and longs going at the same time. I wanted, for instance, to stay in my long until x condition happened not when the next short opportunity came along. Unless there is something that I'm missing (which is possible) there is no way to do this. All that the code knows is that I have a long and now the conditions are right for a short therefore OCO. That is what was happening with the Managed Approach. I thought the Unmanaged Approach had the capacity to take that short and allow the long to continue until x condition was true.
          Am I wrong in my expectations of the Unmanaged Approach?

          Comment


            #6
            CaptainAmericaXX, that expectation is unfortunately not full correct - the strategy you're running would still have one strategy position, meaning if you're long 3 contracts and submit a short for 3, you're not holding both position simultaneously, but instead you would be flat as in the managed approach. If you would like to separate those trades, I would recommend using 2 strategies.

            What the unmanaged approach was designed for is offering the ultimate flexibility in order submission for custom strategies, as the order handling rules are noneffective here - meaning for example you can easily place an entry bracket oco'ed for example, which the managed mode prevented for safeguarding reasons.

            Comment


              #7
              Thank you Bertrand. I have spent dozens of hours banging my head against the wall trying to get longs and shorts going at the same time just so I could put up one strategy instead of 2. However I'm a bit disappointed that I went down that path at all. In a previous post I was told this by Josh,
              You cannot be long and short at the same time with the Managed approach of strategy programming. If you want to do this you will have to use the Unmanaged approach outlined here: http://www.ninjatrader.com/support/h...er_methods.htm
              Can you explain what he meant by this if it is in fact impossible to be long and short at the same time and not be flat?
              Last edited by CaptainAmericaXX; 08-11-2011, 09:54 AM.

              Comment


                #8
                Hi CaptainAmericaXX, from my understanding he meant that you could work non market orders from both sides in one strategy without running into the order handling rules of the managed approach, you could SubmitOrder() as needed without any safeguards in place - however both approaches would have one strategy position as explained.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                672 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                379 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                111 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                575 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                582 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X