Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

my strategy keeps terminating itself

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

    my strategy keeps terminating itself

    I'm running my strategy on a live feed, and every time it my Stop Loss is triggered I get the same error, followed by my strategy terminating itself. 2 dialogue boxes pop up, one that says:

    "Strategy 'MyStrategy' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself."

    and a second box that says:

    "Real Feed(That's what I titled my live feed), Buy stop or buy stop limit orders can't be placed below the market, affect Order: Buy ToCover 200 Stop @ 70.48"

    Any ideas on how to remedy this so I can get back to testing my strategy?

    #2
    milemike,

    Basically your strategy submitted an order that was rejected. This could be due to order handling rules at your broker, or those internal to ninjatrader via the managed approach.



    You can use TraceOrders to see the orders in your output window and then identify which orders were generated that caused this.



    Could you possibly post some of your strategy code here?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by milemke08 View Post
      I'm running my strategy on a live feed, and every time it my Stop Loss is triggered I get the same error, followed by my strategy terminating itself. 2 dialogue boxes pop up, one that says:

      "Strategy 'MyStrategy' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself."

      and a second box that says:

      "Real Feed(That's what I titled my live feed), Buy stop or buy stop limit orders can't be placed below the market, affect Order: Buy ToCover 200 Stop @ 70.48"

      Any ideas on how to remedy this so I can get back to testing my strategy?
      What kind of order are you using for the StopLoss, and is the StopLoss to exit a long position or a short position?

      Comment


        #4
        Right now I simply used SetStopLoss in my Initialize() function, because my focus for now is making sure that I have good market entry points.

        I also have this if statement in my OnBarUpdate()

        Code:
        protected override void Initialize()
                {
                  
        		
        			//specific variables to my strategy 
        			totalDelta1 = 0.0;
        			totalDelta2 = 0.0;
        			currentGR = 0.0;
        			previousGR = 0.0;
        			finalCal = 0.0;
        
        		        //for now, I'm testing my strategy on symbols listed between $30-$50
                                //and would like to drop a position as soon as it drops 1% of the cost, 
                                //which is about $80
        			SetStopLoss(80);
        		
        		}
        
        
        
        /*
        I just use this because, like I said, I'm not yet interested in carrying my positions 
        out and want to exit a position on the very next bar after the one I entered it. 
        For simplicity I'm only using long positions at the moment.
        */
        
        if(Position.MarketPosition == MarketPosition.Long)
        			{
        				ExitLong(200);
        			}




        Originally posted by koganam View Post
        What kind of order are you using for the StopLoss, and is the StopLoss to exit a long position or a short position?
        When you say what kind of order for stoploss, what do you mean?

        Comment


          #5
          Originally posted by milemke08 View Post
          Code:
           
          ... 
                          //for now, I'm testing my strategy on symbols listed between $30-$50
                                  //and would like to drop a position as soon as it drops 1% of the cost, 
                                  //which is about $80
                      SetStopLoss(80);
          Something is off here, though I cannot say that is the cause of the issue. $80 cannot possibly be 1% of $30-$50.

          Correct that and let us see if that was the issue. For sure, $80 StopLoss on a $50 stock puts the StopLoss as a negative number. It is possible that the NT internal code does not take account of negative currency values, and may be wrapping the value, putting things in an inconsistent state. That, of course, for now, is just speculation. Let us get the code making logical sense, then we can tackle any issues that arise.

          When you say what kind of order for stoploss, what do you mean?
          You answered that one. You are using Market orders, which makes your problem all the more surprising.

          Comment


            #6
            Oh, I'm sorry I forgot to mention that I'm dealing with 200 shares at a time. I need my positions to be very liquid so I keep that number low. Now, 1% of 200 shares at $30-50 is $80, that's what I meant. Sorry I forgot to mention that.

            Comment


              #7
              I am sure I missed a post on this somewhere but - i dont want my strategy to terminate b/c of a bad order rather just keep submitting until the order is filled - is that a setting under Options or needs to coded?

              Comment


                #8
                Hello milemke08,

                You can prevent your strategy from disabling when receiving a rejection by setting the RealTimeErrorHandling in Initialize().

                For example:
                RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;

                Below is a link to the help guide on RealTimeErrorHandling.
                http://www.ninjatrader.com/support/h...orhandling.htm
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                3 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                18 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                1 view
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                6 views
                0 likes
                Last Post Javierw.ok  
                Started by timmbbo, Today, 08:59 AM
                2 responses
                10 views
                0 likes
                Last Post bltdavid  
                Working...
                X