Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

RE: Stoploss orders stay Initialized {372020}

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

    #16
    Because you have both statements, it's not clear which one would be executed on either account.

    There was a related bug here. You need to isolate to one type of stop loss statement, and definitely test on our next beta.
    Ryan M.NinjaTrader Customer Service

    Comment


      #17
      Allright. I'll test with the new strategy/release and report back the results.
      Thanks!

      Comment


        #18
        Looks like it solved the problem, my stoplosses are sent to the TWS now.

        Comment


          #19
          Well, there's a new issue in connection with this one.
          Since I disabled my stoploss resetting code (the one with the simulated stop set to the minimum price(near 0 ~ TickSize)), my stoplosses are going crazy. NT submits my old stoploss first, and then it changes to the new one. The problem is that it sometimes gets rejected, because it's an invalid (above the market price for long) price.
          For example:
          At a previous position my stoploss was at 119.52. My strategy exits that position. Later it enters again and my stoploss is set to 119.52, though it should be set to 119.4. My stoploss then changes to 119.4. However on the next position it tries to set the stoploss to an invalid price(119.4) (above the market), and thus my stoploss is rejected.

          How do I disable the stoploss when my strategy exits, so that the next time there isn't any stoploss order submitted until the next time I call SetstopLoss?

          Your help is very misleading:
          you should always reset the stop loss price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position
          I was resetting the stoploss, but it was causing my stoploss orders not to be sent at all (the first issue in this topic).

          Something is messed up with the stoploss handling.

          Comment


            #20
            Hello vides2012,

            You will have to debug the price level that you're submitting orders at. If you want to ensure that stop loss price is valid, it may help to use calculation mode ticks or percent. These will then be based from an offset of the entry price.

            If you are submitting stop loss orders with mode price, there is nothing stopping you from submitting invalid orders.

            If you'd like more control over the submission of stop orders, you can also use ExitLongStop() or ExitShortStop().
            Ryan M.NinjaTrader Customer Service

            Comment


              #21
              My price levels are correct, though as I have mentioned the price level from the previous SetStopLoss call remains, and that price level is now obsolete and invalid.

              How do I disable this, so that on the next entry there isn't any stoploss order until I call again SetStopLoss? Or how do I reset the stoploss? As you can see my previous solution (the one at the beginning of this topic) was working from this point of view. However it caused NT work unpredictably while trading live.

              There must be a solution to this. I would like to set the stoploss according to the entry circumstances of the position (average price to be more specific). Setting the stoploss in the OnExecution seems to be the hard way due to these behaviors of NT.

              Either please resolve the live trading issue (when having resetted stoploss orders, the actual ones don't become alive), or provide a way to propely disable the stoploss so that it doesn't activate on next entry.

              Comment


                #22
                I'm still waiting for a plausible solution to this.

                Comment


                  #23
                  vides, to clarify how you work your code - when you're flat in the strategy position : do you reset to default value like in this sample here?



                  Thanks

                  Comment


                    #24
                    The default value in my case is not to have a stoploss. In my initial version I was resetting the stoploss to be simulated, so that it wouldn't interfere. But that caused NT not to send the real, not simulated order later, so I removed the resetting mechanism.

                    Can you propose a way to properly reset the stoploss to a non-working state?

                    Thanks.

                    Here's the initial code:

                    Code:
                    protected override void OnExecution(IExecution execution)
                    		{
                    			IOrder ord=execution.Order;
                    			base.OnExecution(execution);
                    			//If we have just bought (entered into long)
                    			if(ord.OrderAction==OrderAction.Buy && ord.OrderType != OrderType.Stop && Position.Quantity>0)
                    			{
                    				SetStopLoss(Name+" EnterLong",CalculationMode.Price,avgPrice+l_ln/(Position.Quantity),false);	
                    				SetStopLoss(Name+" EnterShort",CalculationMode.Price,TickSize,true); //reset the short stoploss
                    				
                    			}
                    			//IF we have just sold (entered into short)
                    			else if(ord.OrderAction==OrderAction.SellShort && ord.OrderType != OrderType.Stop && Position.Quantity>0)
                    			{
                    				SetStopLoss(Name+" EnterShort",CalculationMode.Price,avgPrice-s_ln/(Position.Quantity),false);	
                    				SetStopLoss(Name+" EnterLong",CalculationMode.Price,TickSize,true); //reset the long stoploss
                    				
                    			}
                    			else //not in position anymore
                    			{
                    				//reset both stoplosses
                    				SetStopLoss(Name+" EnterShort",CalculationMode.Price,TickSize,true);
                    				SetStopLoss(Name+" EnterLong",CalculationMode.Price,TickSize,true);	
                    				
                    			}
                    			
                    		}
                    As you can see, when the strategy exits the position I reset the stoploss to a simulated state, but after entry I set it again to a functioning state. But it didn't work out well, as NT denied to send the new, real, not simulated stoploss order to the TWS.
                    Last edited by vides2012; 10-08-2010, 07:07 AM.

                    Comment


                      #25
                      You would need to work with the Exit() methods then, as you cancel and replace those as needed - the Set() are unfortunately not 'cancellable', thus we normally suggest just moving the stop very far away to effectively neutralize it. You can then draw it closer when you would need it again.

                      Comment


                        #26
                        Well, actually I was doing that - moving far away to the minimum price available (TickSize, since it cannot be 0), and also using simulated orders.
                        The problem is that this far-placed live stoploss would actually be sent to the TWS, and, even for a moment would be active. It would interfere with my other orders, wouldn't it? These short lifed stoploss orders can mean trouble if they are not cancelled (for any reason).

                        I would consider adding a DisableStopLoss(string entryName) function. Or looking into, why doesn't NT send the live order, after having the simulated one! This one's not clear to me, why can't I have both simulated and live stoplosses.

                        Comment


                          #27
                          vides, correct it could interfere depending on your scenario - you should move to the Exit() methods to accomplish this, since they would offer you the explicit control you seek / need.

                          Thanks for the suggestion to add a dedicated method for the Set's.

                          Comment


                            #28
                            By Exit() methods you suggest using ExitLongStop()/ExitShortStop() instead of setting the stoploss for long and short position with SetstopLoss()?

                            Comment


                              #29
                              Originally posted by vides2012 View Post
                              By Exit() methods you suggest using ExitLongStop()/ExitShortStop() instead of setting the stoploss for long and short position with SetstopLoss()?
                              Yes, correct that would be my suggestion here.

                              Comment


                                #30
                                Allright, I'll look into it. Thanks for the support!

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                626 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                359 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                105 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                562 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                567 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X