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

ExitLongLimit issue.

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

    ExitLongLimit issue.

    Hello,
    I am trying to exit a position with ExitLongLimi(). This is what I coded:

    protected override void OnBarUpdate()

    if (Closes[1][0] > SMA(BarsArray[1], 250)[0]
    && !HasTradedLong)

    {
    HasTradedLong = true;
    OpenStop = Open[0];

    EnterLongLimit(100, Close[0], "");

    }

    if (Close[0] < OpenStop)
    {
    ExitLongLimit(Close[0]);

    }


    My entry orders are working, but exits do not.

    Am I doing something wrong here?



    Thanks


    #2
    Hi strategy1, are you sure your exit condition evaluates to true?

    You could add Print() statements at critical points to your code to doublecheck your conditions hit home, here's a tip about this topic -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Evaluates to True - but doesn't execute.

      I added:

      Print(Time[0].ToString());
      Print(OpenStop);

      and it does evaluate to True, but doesn't execute.

      Comment


        #4
        Since you try to place a exit limit order at the Close[0] you may not get filled and the order expires at the end of the bar. Did you enable TraceOrders to debug - http://www.ninjatrader-support2.com/...ead.php?t=3627

        Also: did you get any errors in the Log tab of the Control Center?
        Last edited by NinjaTrader_Bertrand; 01-15-2009, 12:11 PM.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          It makes sense if the sell order doesn't execute because it is trying to get the price of Close[0], which may no longer be at that point.

          It also makes sense that the order expires at the end of the bar.

          But it once again becomes an active order on the next bar that the condition is true, Which in my case is 5 bars later. And if the price is there at this point it should work. Yet it still doesn't execute.

          Comment


            #6
            Hi, have you checked the TraceOrders feedback in the Control Center output window? Please post the results here, so we can take a look - Thanks!
            BertrandNinjaTrader Customer Service

            Comment


              #7
              TraceLog

              Here is the trace log.

              The condition for the exit is true on the very next bar, but the price is not there already, thus it doesn't execute.

              But at 1:30 the condition is true and the price is there yet it still doesn't execute.

              Is there anything else I am missing or coding wrong?

              Comment


                #8
                You forgot the attachment.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Will this be OK?

                  The file is too big to be attached. Will this be OK?



                  1/15/2009 5:31:21 PM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='' Mode=Ticks Value=0 Currency=500 Simulated=False
                  1/6/2009 12:50:00 PM Entered internal PlaceOrder() method at 1/6/2009 12:50:00 PM: Action=Sell OrderType=Limit Quantity=0 LimitPrice=34.32 StopPrice=0 SignalName='' FromEntrySignal=''
                  1/6/2009 12:50:00 PM Ignored PlaceOrder() method at 1/6/2009 12:50:00 PM: Action=Sell OrderType=Limit Quantity=0 LimitPrice=34.32 StopPrice=0 SignalName=Sell' FromEntrySignal='' Reason='An Exit() method to submit an exit order has been ignore. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.'
                  1/6/2009 12:55:00 PM Entered internal PlaceOrder() method at 1/6/2009 12:55:00 PM: Action=Sell OrderType=Limit Quantity=0 LimitPrice=34.27 StopPrice=0 SignalName='' FromEntrySignal=''
                  1/6/2009 1:40:00 PM Entered internal PlaceOrder() method at 1/6/2009 1:40:00 PM: Action=Sell OrderType=Limit Quantity=0 LimitPrice=34.30 StopPrice=0 SignalName='' FromEntrySignal=''
                  1/6/2009 1:45:00 PM Entered internal PlaceOrder() method at 1/6/2009 1:45:00 PM: Action=Sell OrderType=Limit Quantity=0 LimitPrice=34.35 StopPrice=0 SignalName='' FromEntrySignal=''
                  1/6/2009 3:55:00 PM Cancelled pending exit order, since associated position is closed: Order='NT-00001/Back101' Name='Profit target' State=Working Instrument='ABX' Action=Sell Limit price=35.09 Stop price=0 Quantity=1,000 Strategy='MorningBreakout' Type=Limit Tif=Gtc Oco='NT-00000' Filled=0 Fill price=0 Token='9ef1593b47a9493ebb8f5c0a9d41ca37' Gtd='12/1/2099 12:00:00 AM'

                  Comment


                    #10
                    This is the problem: "An Exit() method to submit an exit order has been ignore. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation."

                    You need to debug why you are hitting one of the rules. Please review all of them in the Help Guide: http://www.ninjatrader-support.com/H...verview36.html
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Still doesn't work.

                      I've read the article a few times and tried to debug.
                      Still can't get it to work. There must be something else that I am missing...

                      Thanks

                      Comment


                        #12
                        Hello,

                        Maybe this link will help with debugging:
                        DenNinjaTrader Customer Service

                        Comment


                          #13
                          Still Can't Figure it out.

                          I read it and added DrawDot,
                          I still can't get a handle on why it doesn't execute that line of code.

                          One thing I did notice (although I do not think related) is that I get a wrong entry price and time (completely wrong) on the first day of the backtest only. Why would this be?

                          Also, why would the ExitLongLimit order be ignored in my code?

                          I would greatly appreciate anyone's help on this.

                          Comment


                            #14
                            strategy1,

                            The Internal Order Handling Rules states this:

                            Code:
                            Methods that generate orders to exit a position will be ignored if a strategy position is open and:[LIST][*]An order submitted by a set method ([URL="http://www.ninjatrader-support.com/HelpGuideV6/SetStopLoss.html"]SetStopLoss()[/URL] for example) is active[/LIST]
                            That is what you are hitting. You have SetStopLoss active so you cannot use an explicit exit method unless that method was for a market order.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              That's not it.

                              Josh,

                              That is not what it is. I have commented out my SetStopLoss when I first read the article on order handling, as per your suggestion.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Rogers101, 05-05-2024, 11:30 AM
                              7 responses
                              29 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by knowmad, Today, 03:52 AM
                              1 response
                              19 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by llanqui, Yesterday, 03:51 PM
                              5 responses
                              23 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by MSerag, Yesterday, 11:52 PM
                              1 response
                              17 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by tradingnasdaqprueba, Today, 03:42 AM
                              1 response
                              18 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X