Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitLongStopLimit()

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

    ExitLongStopLimit()

    I'v seen this mentioned inthe forum before.

    ExitLongStopLimit() does not work. Or at least it doesn't do anything similiar to its counterparty ExitShortStopLimit.

    I have also noticed that ExitLongStopLimit() causes the Strategy to stop running...all the log and trace files stop once it is executed.

    Can someone advise please or offer a work around?


    C

    #2
    Hello C,

    Thank you for your post.

    I am not sure why ExitLongStopLimit() does not work for you. So I may investigate this matter further please answer the following questions.
    • Who are you connected to? This is displayed by green on lower left corner of the Control Center window.
    • What instrument(s) have you selected? If a futures instrument, what expiry is selected? (Example: ES 06-13)
    • Do you receive an error on screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?

    I look forward to your response.

    Comment


      #3
      Who are you connected to? This is displayed by green on lower left corner of the Control Center window.Ans..... I am using market replay data from Nov 7h 2014
      What instrument(s) have you selected? If a futures instrument, what expiry is selected? (Example: ES 06-13) Ans......GC 12-14
      Do you receive an error on screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report? - Ans....Nothing

      Comment


        #4
        ExitShortStopLimit(tickPrice +1, tickPrice

        The relevant snippet of code.It works when I am covering a Stop for Long but not the short in the else statement


        if (Position.MarketPosition == MarketPosition.Long)
        /* 1 ) Move the Stop Loss in the appropriate Direction
        */
        {
        tickPrice = Close[0];
        if (tickPrice >= pTickPrice) //Market is still rising
        {

        ChangeOrder(stopOrder, 1, tickPrice -1 * TickSize, tickPrice -1 * TickSize);
        pTickPrice = Close[0]; /// for tick price comparision at the next iteration
        }
        else {

        exitLong = ExitLongStopLimit(tickPrice -1, tickPrice -1); //Just get out!!
        exitShort = ExitShortStopLimit(tickPrice -1, tickPrice -1); //Just get out!!

        }

        }


        else if (Position.MarketPosition == MarketPosition.Short)
        {
        tickPrice = Close[0]; // what is the current Market price
        if (tickPrice <= pTickPrice) //Market is still falling
        {
        ChangeOrder(stopOrder, 1, tickPrice +1 * TickSize, tickPrice +1 * TickSize);
        pTickPrice = Close[0]; /// for tick price comparision at the next iteration
        }
        else {
        exitShort = ExitShortStopLimit(tickPrice +1, tickPrice +1); //Just get out!!
        exitLong = ExitLongStopLimit(tickPrice +1, tickPrice +1); //Just get out!!
        }

        Comment


          #5
          Hello cocopod,

          Thank you for your response.

          You cannot use both ExitShortStopLimit() or ExitLongStopLimit() at the same time, this will cause one to be cancelled per the internal handling rules at the following link: http://www.ninjatrader.com/support/h...d_approach.htm

          In addition, you are using ChangeOrder() which is used to amend an Unmanaged order. Are you using Unmanaged orders and Managed orders together in the same strategy?

          Comment


            #6
            Hi... actually one of your colleagues pointed out earlier that I can't use ExitLongStopLimit in Unmanaged orders.

            I am trying to find another way to close the orders when the stop loss is hit in an unmanaged order.

            any suggestions?

            Comment


              #7
              Hello cocopod,

              CancelOrder() would be used to cancel the orders.

              Comment


                #8
                CancelOrder() only closed the market position but left the pending short. Is this to be expected? see the code below


                //CancelOrder(shortOrder); a Contract in the market
                //CancelOrder(stopOrder); a pending Stop loss


                c

                Comment


                  #9
                  Hold the front Page!!!

                  //CancelOrder(shortOrder); a Contract in the market
                  //CancelOrder(stopOrder); a pending Stop loss

                  Actually it was the other way around - it closed teh pending short but left the market position!!!

                  Comment


                    #10
                    Hello,
                    Yes the expected behavior for CancelOrder() will cancel the pending order but will not close your position.
                    When you are in a position you will need submit an exit order.
                    If you are in a long order ,and you want to exit your position, you will want to use the ExitLong() method.
                    If you are in a short postion, and you want to exit your postion, you will want to use the ExitShort() method.

                    Here is a link to our help guide on how to use the ExitLong() method. http://www.ninjatrader.com/support/h...htsub=exitlong
                    Here is a link to our help guide on how to use the ExitShort() method.
                    http://www.ninjatrader.com/support/h...tsub=exitshort
                    If I can be of any other assistance please let me know.
                    Cody B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Cody,

                      I am using an Unmanaged position and therefore cannot use the

                      ExitShort() method

                      Please advise how I can exit the position

                      C

                      Comment


                        #12
                        If you're using the Unmanaged approach, then there are no convenience layers available to manage the position. In that case, you need to explicitly submit an order in the opposite direction of your current position using SubmitOrder()

                        MatthewNinjaTrader Product Management

                        Comment


                          #13
                          Hi cocopod,

                          Using the unmanaged approach, to exit a trade, submit an order in the opposite direction of the position.

                          For example:

                          if (Position.MarketPosition == MarketPosition.Long)
                          {
                          SubmitOrder(0, OrderAction.Sell, OrderType.Market, 1, 0, 0, "", "myExit");
                          }

                          Below is a link to the help guide on SubmitOrder(). When using the unmanaged approach, all orders, including exits will be submitted with SubmitOrder().
                          http://www.ninjatrader.com/support/h...ubmitorder.htm
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Thanks alot guys...Do I have to pay any special attention to the ocoid? I know I used it with the bracket trade so that one side cancelled the other. does the same apply when using the submitOrder to cancel an existing order?

                            Comment


                              #15
                              Hello cocopod,

                              Thank you for your response.

                              SubmitOrder() would not cancel an order but in the examples from Matthew and Chelsea it would close an open position.

                              The ocoid should be "" for this new order to close the position:
                              Code:
                              SubmitOrder(0, OrderAction.Sell, OrderType.Market, 1, 0, 0, [B]""[/B], "myExit");

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              671 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