Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop to reverse and stop to exit

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

    Stop to reverse and stop to exit

    The code below runs OK when the else section is commented out (as shown). However when the else section is included I get the error message "An Enter() method to submit an entry order at '1/9/2008 12:05:00 PM' has been ignored. ..."

    I have no idea why this error exists. In the case when the else section is commented out the scheme simply goes short at the open of the second bar which occurs at 9:40 AM (I'm using 5 minute bars). Then at 10:00 AM an order to reverse the position is given if the stop is hit. This is acceptable to NT.

    However, when the else section is included, I get the above error message. In essense what I want is for for the "stop and reverse" order to cancel itself at 12:00PM and then for a "stop and exit" order to be submitted at 12:05 PM. I'm not clear at all why I can't do this. Any pointers would be appreciated.



    protectedoverridevoid OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBar < 10)
    return;


    if (Bars.FirstBarOfSession)
    {
    EnterShort();
    }


    if (Position.MarketPosition == MarketPosition.Short)
    {
    if ( (ToTime(Time[0]) >= 100000) && (ToTime(Time[0]) <= 120000) )
    {
    EnterLongStop(
    20000.0);
    }
    /* elseif ( (ToTime(Time[0]) > 120000) )
    {
    ExitShortStop(20000.0);
    }
    */

    }
    }

    #2
    Hi jonesr227,

    One of our technicians training in NinjaScript will respond later today. Thank you for your patience.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      You provided:
      "An Enter() method to submit an entry order at '1/9/2008 12:05:00 PM' has been ignored. ..."

      Please provide the entire error message.
      DenNinjaTrader Customer Service

      Comment


        #4
        The full message is:

        "An Exit() method to submit an exit order at '1/9/2008 12:05:00 PM' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation."

        It now says Exit rather than Enter(?). My question still stands.

        Comment


          #5
          jonesr227,

          Please check out this link: http://www.ninjatrader-support.com/H...verview36.html

          The rule pertaining to you is this:
          Methods that generate orders to exit a position will be ignored if a strategy position is open and:
          • An order submitted by an enter method (EnterLongLimit() for example) is active and this entry order is used to open a position in the opposite direction
          You already have a short position and then you have an EnterLongStop() so you cannot submit an ExitShort().
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            You already have a short position and then you have an EnterLongStop() so you cannot submit an ExitShort().
            I have a short position established at 9:40 then an EnterLongStop is operational from 10:00 to 12:00. Then at 12:05 onwards an ExitShort becomes operational. What's the problem with that?

            In actual trading EnterLongShort will submit two orders: 1) cover one contract, 2) go long one contract. When the ExitShort command appears it will simply cancel the second order i.e. "go long one contract" will be cancelled.

            How can I get my desired operation from NT?

            Comment


              #7
              According to your prints your EnterLongStop() is still active when you submitted your ExitShort() otherwise it wouldn't complain.

              To get your desired operation you will need to wait for your EnterLongStop() to be cancelled before you can submit ExitShort(). Not resubmitting your EnterLongStop() will lead to its cancellation. Until it has fully cancelled you will not be able to submit ExitShort().
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Josh View Post
                According to your prints your EnterLongStop() is still active when you submitted your ExitShort() otherwise it wouldn't complain.
                I hope you see that this is a bug in NT. (By the way, Wealth Lab 4.0, which is no longer supported, handles this situation properly. I'm hoping to upgrade to NT).


                To get your desired operation you will need to wait for your EnterLongStop() to be cancelled before you can submit ExitShort(). Not resubmitting your EnterLongStop() will lead to its cancellation. Until it has fully cancelled you will not be able to submit ExitShort().
                Can I get my desired operation using "advanced" commands like OnExecution() and/or OnorderUpdate()?

                With the present situation, I will need to leave a 5 minute gap (since I'm using 5 minute data) between when the EnterlongStop orders are cancelled and the ExitShort order is initiated; thus a 5 minute interval where no stop is present (clearly a bug).

                Comment


                  #9
                  jonesr227,

                  This is not a bug. This works exactly how it should. If we allowed you to submit an ExitShort() order when you already have an EnterLongStop() working against a short position you could very easily be filled on both the EnterLongStop() and ExitShort(). This would result in double the long position and this is why we have such a rule in place.

                  Run with CalculateOnBarClose = false. Or use IOrders and then manually use the CancelOrder() when you want an order gone and submit your new one when appropriate.
                  Josh P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  566 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  330 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  101 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  547 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  548 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X