Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

replace stoploss

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

    replace stoploss

    Hello,

    I want to replace a stoploss by another stoploss referring to certain conditions. I´m working with IOrder and ExitLongStop (instead of "setstoploss").

    With IOrder and ExitLongStop now I can a.) change the certain stoploss and I can b.) cancel a certain stoploss. But I can not c.) bring up a new stoploss in the trade.

    How can I do please to bring a new stoploss in the trade (after I have cancelled another one)

    Thanks
    Tony

    #2
    Tony, I would then suggest not to fully cancel the stop loss, but just update it by calling the ExitLongStop with your changed value again working on the same order / signal name, this will amend as needed.

    Comment


      #3
      Hello Bertrand,

      thank you for your reply. I need to do by cancelling and bringing up a new stoploss for certain reasons.

      Please, can you tell me how this one step - I dont know - can be done to cancel a stoploss and bringing up a new one?

      Thank you very much.

      Best
      Tony

      Originally posted by NinjaTrader_Bertrand View Post
      Tony, I would then suggest not to fully cancel the stop loss, but just update it by calling the ExitLongStop with your changed value again working on the same order / signal name, this will amend as needed.

      Comment


        #4
        Tony, this can be done as well, I just wanted to recommend the other approach to not leave your position 'naked'.

        Comment


          #5
          Bertrand,

          thank you for your reply and your hint. Referring to my question here at the beginning, please how can I do? I can change and cancel but not bring in a new stop. Now I do

          if (stopOrder1 != null && stopOrder1.StopPrice < Position.AvgPrice)
          CancelOrder(stopOrder1);
          stopOrder2 = ExitLongStop(0, true, stopOrder2.Quantity, Position.AvgPrice - 10 * TickSize, "MyStop2", "Entry1");

          What might be wrong here?

          Thanks
          Tony








          Originally posted by NinjaTrader_Bertrand View Post
          Tony, this can be done as well, I just wanted to recommend the other approach to not leave your position 'naked'.

          Comment


            #6
            Tony, you would need to wait for the CancelOrder call to be processed, so issue the new stop only if you're seeing a confirmed .Cancelled orderstate for example in OnOrderUpdate().

            Comment


              #7
              Bertrand,

              thank you very much for your reply. Can you PLEASE show me a snippet how to check "confirmed. Cancelled orderstate". As I can not find this in the both NT-samples I have I can not do this.

              Thanks
              Tony

              Originally posted by NinjaTrader_Bertrand View Post
              Tony, you would need to wait for the CancelOrder call to be processed, so issue the new stop only if you're seeing a confirmed .Cancelled orderstate for example in OnOrderUpdate().

              Comment


                #8
                Tony, this technique would be for example used in our SampleOnOrderUpdate() sample here - http://www.ninjatrader.com/support/f...ead.php?t=7499

                When you cancelled order sees this state in OnOrderUpdate(), you can go ahead and reissue the new one.

                Comment


                  #9
                  Hello Bertrand,

                  this way(?):

                  protected override void OnOrderUpdate(IOrder order)
                  {

                  if (stopOrder1 == null && stopOrder1 == order)
                  {
                  if (order.OrderState == OrderState.Cancelled && order.Filled == 0)
                  {
                  stopOrder2 = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 24 * TickSize, "MyStop2", "Entry1");
                  }
                  }


                  Thanks
                  Tony

                  Comment


                    #10
                    Tony,

                    Yes, that should check that the order has been canceled.
                    MatthewNinjaTrader Product Management

                    Comment


                      #11
                      Hello,

                      (you might know that this "that should work" gives error-messages??)

                      I do changing my stopmanagement from setstoploss to IOrder with exitlongstop.

                      I do not change stops, I bring in a new stop and cancel the old one. I can also do this but I want to cancel the "old" stop only once I know that the "new" stop is accepted.

                      With the samples OnBarUpdate and CancelOrder I understand how to bring in the initial stoploss with OnExectution.

                      But how to check that "stopnew" is accepted? Is this to check with OnOrderUpdate or with OnExecution? When is stopOrdernew != null? How can I do this please?

                      Thanks
                      Tony

                      Comment


                        #12
                        Correct Tony, you would then check in OnOrderUpdate() if the new stop is in .Accepted state and if it is > you could go ahead and issue the CancelOrder() for the old one that you don't wish to use anymore.

                        Comment


                          #13
                          Hello,

                          thank you for your confirmation.

                          And thank you for all your support!

                          Best software - best support!


                          But there occurs a new problem now: ExitLong doesnt work once I have cancelled initial stoploss and setup a new stoploss. I do not change anything in ExitLong.

                          Thanks
                          Tony
                          Last edited by tonynt; 12-22-2012, 04:56 AM. Reason: ExitLong doesnt work anymore

                          Comment


                            #14
                            Thanks for the kind words Tony.

                            Are you sure the condition for ExitLong is triggering like expected? Any signal names potentially changed that would lead to this call being just ignored? Anything noteworthy in your trace order outputs?

                            Comment


                              #15
                              Hello,

                              I could solve everything to replace stoplosses instead of moving them. But now occurs a new problem. When there is an exit triggered then all my stops are not there anymore. EG Position I have 3000 and status of 3000 stoporders is accepted. Once exit 1000 is realized the stops are not there!? (Positions are correct with 2000). This is a snippet of the script:

                              if (Position.MarketPosition == MarketPosition.Long && Close[0] >= Position.AvgPrice + (8 * TickSize))
                              {
                              if (stopOrder2!= null && stopOrder2.StopPrice >= Position.AvgPrice)

                              stopOrder3 = ExitLongStop(0, true, 3000, Position.AvgPrice+ (5 * TickSize) , "MyStop3", "MyEntry1");
                              }

                              If (Position.Quantity == 3000 && GetCurrentAsk(0) > Position.AvgPrice + 15 * TickSize)
                              ExitLong(1000, "x1","MyEntry1");

                              Thanks
                              Tony



                              Originally posted by NinjaTrader_Bertrand View Post
                              Thanks for the kind words Tony.

                              Are you sure the condition for ExitLong is triggering like expected? Any signal names potentially changed that would lead to this call being just ignored? Anything noteworthy in your trace order outputs?
                              Last edited by tonynt; 01-06-2013, 09:32 AM. Reason: clearify

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Today, 05:17 AM
                              0 responses
                              23 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              120 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              63 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              41 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              45 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X