Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamically changing the stop / proit target while in the market

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

    Dynamically changing the stop / proit target while in the market

    I can't seem to change my stop price using SetStopLoss while I have entered a position. First I set the stop price, then enter the market. I can see that the order is filled and I have a stop order that is set to my first stop value. The OnBarUpdate (CalculateOnBarClose=true) executes and I call a function on the next bar to reset the Stop. I change SetStopLoss value to a new value. The order is not updated in the Control Panel and the order does not fill at the new stop.

    I read this in the help:
    You may call this method from within the strategy OnBarUpdate() method should you wish to dynamically change the stop loss price while in an open position.

    Any suggestions? Is there a way to cancel the Stop order and reissue a new one? I could try using SetTrailLoss. But I also have the same issue with SetProfitTarget.

    I am in simulation mode.

    #2
    TradingDreamer,

    You should be able to modify the order. Perhaps this reference sample will give you some hints on how to do it: http://www.ninjatrader-support2.com/...ead.php?t=3222

    You cannot cancel a SetStopLoss() order through code. If you want this functionality you would be better served using explicit exit methods like ExitLongStop() or ExitShortStop() and then calling CancelOrder() on them.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi
      I am developing a strategy that has several different type of entries with different stops and targets. Some of these entries will require the program to enter a limit order and cancel that limit order if a certain condition is met. I took a look at the sample strategy that uses "CancelOrder" to cancel a limit order. However, I wasnt able to figure out how I would be able to use that function to set stop loss and targets for different types of entries that have different stops and targets. Can someone please advise or direct me to a source that can help me.

      Thanks

      Comment


        #4
        Have you looked already at this sample below? It would deal with how to tie different signals together through their signal naming - http://www.ninjatrader.com/support/f...ead.php?t=3225

        Comment


          #5
          Ok, I took a look it and it did not help at all. What I want to do is to use Iorder to cancel specific entry type and also to set specific stops and targets for different entry types.

          Thanks

          Comment


            #6
            Hello,

            First off are you using the managed approach or the unmanaged approach as you cannot mix between the two, you most use one or the other.

            The reason is you mention IOrders which is a unmanaged approach method. You would only use iOrder if you wanted to use the Unmanaged approach.

            Otherwise you will use ExitShort() or ExitLong() with a signal name like in Berts example to exit out of the position and not use IOrder.

            PLease let me know so that I can link you to correct sample material.
            BrettNinjaTrader Product Management

            Comment


              #7
              I am not a programmer so I am not sure what you mean by managed and unmanaged approach. My program has several entry criteria that sends limit orders. what I am trying to do is to have those limit order cancel if certain conditions are met. Each entry type has its own condition to be met for its limit order to be cancel. also, I would like to work with limit orders that are live until they are cancel. please advise how to best approach this.

              Thanks

              Comment


                #8
                trader413,

                Unfortunately to achieve what you want would require programming. I would recommend perhaps trying one of these 3rd party NinjaScript consultants to program the strategy for you: http://www.ninjatrader.com/webnew/pa...injaScript.htm

                But in general, the way to proceed is to have an IOrder object assigned to each of your limit orders. Then you can program whatever separate conditions you want for them to cancel off of. So for example something like this:

                Code:
                if (Close[0] < Open[0])
                     CancelOrder(limitOrder1);
                
                if (Close[0] < Close[1])
                     CancelOrder(limitOrder2);
                For live until cancelled orders you would need to use the correct EnterLongLimit() or EnterShortLimit() signature. http://www.ninjatrader-support.com/H...LongLimit.html In that Help Guide article you will find only one listed signature with a liveUntilCancelled parameter. That is the one you want to use.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Ok so my variable region would look like this below ?


                  private IOrder limitOrder1 = null;
                  private IOder limitOrder2 = null;
                  private IOrder stopOrder1 = null;
                  private IOrder stopOrder2 = null;
                  private IOrder targetOrder1 = null;
                  private IOrder targetOrder2 = null;

                  Comment


                    #10
                    Yes, then you would actually need to assign an order to them when you want to place a trade.

                    limitOrder1 = EnterLongLimit(....);
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      ok got it. Another question, my next step in developing my system is to develop codes that will allow my system to constantly scale in and out after a position has entered. How would I approach this using the unmanaged IOrder approach ?

                      Thanks

                      Comment


                        #12
                        For unmanaged orders all you have to do is keep calling SubmitOrder() and add to your position or remove from your position. http://www.ninjatrader.com/support/h...ubmitorder.htm
                        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
                        633 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        364 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
                        567 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        568 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X