Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to prevent stop loss order from changing

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

    How to prevent stop loss order from changing

    if (atmStrategyId.Length > 0)
    {
    // You can change the stop price
    if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
    AtmStrategyChangeStopTarget(
    0, Low[0] - 3 * TickSize, "STOP1", atmStrategyId);
    }


    Hi, I am using the sample ATM strategy code (above) to place stop loss order. But, I would like the stop to be set at order entry and don't want it to change on each bar update. Any suggestions on how i can achieve this?


    Currently the stop price is updating on each bar update, so i tried putting the code in OnBarUpdate(), but the stop did not even change at entry, it just used my default ATM strategy settings.


    Thanks for your help in advance.

    #2
    Hi dawdler,

    The code snippet you posted is designed to change the level of the stop loss. If you don't want it changed you can remove that line completely.

    If you only want it executed on bar close and not tick by tick, this is controlled with the CalculateOnBarClose settings.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      thanks for your reply Ryan, but...


      how can i change my stop order for each entry based on the ATR() value?

      for example my ATM strategy template has a 20 tick stop loss, but if the ATR is 30 ticks - I want the stop to move to 30 ticks at entry and remain unchanged. Is this possible?


      thanks for your time
      p/s i don't want to use the set stop loss because its market order only
      Last edited by dawdler; 04-01-2011, 02:25 PM.

      Comment


        #4
        In your code snippet, you change price to Low[0] - 3 * TickSize. If you want to change to an indicator or a different calculated value, then you put that value instead.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I am sorry, what price are you are referring to


          ...i just want the stop price to be set at Low[0]-3*TickSize once a position is open and stay there without it being updated on each bar. is that possible?


          this is what i am trying to use: but the stop price keeps changing at each bar's close. I just want it to change from my default ATM template setting at the beginning and stay there...
          AtmStrategyChangeStopTarget(0, Close[0] - ATR(100)[0], "STOP1", atmStrategyId);
          Last edited by dawdler; 04-01-2011, 03:04 PM.

          Comment


            #6
            Yes, it's possible but you may want to move away from using ATM strategies as the design intent of these is to connect a NinjaScript strategy to an ATM strategy for management. ATM based stop losses are typically placed at tick or percent offsets from an entry price. If you want to place orders at price or indicator or price levels, then a standard NinjaScript strategy will do this.

            The command you're using is to change the price level. If you only want that command processed once then you have to custom code a control for this, commonly through bool flags.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              thanks for your help so far Ryan, i will stop trying to use the ATM strategies for placing stop loss orders...

              is there a standard Ninjascript strategy that meets the following criteria?
              - OCO Stop loss and profit target
              - Stop limit orders not stop market
              - Stop loss and target order must be submitted at the entry
              - Stop loss must not change on each bar update once submitted


              Yes, it's possible but you may want to move away from using ATM strategies as the design intent of these is to connect a NinjaScript strategy to an ATM strategy for management. ATM based stop losses are typically placed at tick or percent offsets from an entry price. If you want to place orders at price or indicator or price levels, then a standard NinjaScript strategy will do this.

              The command you're using is to change the price level. If you only want that command processed once then you have to custom code a control for this, commonly through bool flags.
              Last edited by dawdler; 04-01-2011, 03:30 PM.

              Comment


                #8
                You can custom code a strategy that does this, although I'm not aware of a strategy template that offers all those qualifications.

                If you are getting started with strategy development in NinjaTrader, I reccomend taking a look at this page on the strategy development process. The strategy wizard is a good place to start as you can create conditions in a point and click interface.

                If you are looking for custom coding services, we have partners that offer this. You can see our NinjaScript consultants available here.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  okay i will take your advice, thanks for your time Ryan!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  647 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  369 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  108 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  572 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  573 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X