Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set StopLoss in ATMStrategyCreate()

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

    How to set StopLoss in ATMStrategyCreate()

    In the Sample ATM Strategy delivered with NinjaTrader, the method used to submit a new ATM order is:

    AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);

    The stoploss value is set to 0. Let's say I want the stoploss to be 10 ticks below the Low[0]. So I use:

    AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], Low[0] - (10 * TickSize), TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);


    However, when this code executes, the stop is not set to Low[0] - (10 * TickSize), it's set to whatever my stoploss value is in AtmStrategyTemplate. I tried setting a 0 stoploss value in AtmStrategyTemplate, but it won't let me. So how do I get AtmStrategyCreate() to submit the order with the stoploss price I want?

    Thanks!
    Bryan

    #2
    Hello,

    Thanks for the note.

    The stop loss price is not changed by the ATMStrategyCreate() method. It is done by the ATM Strategy template. Also, you cannot have a stoploss of 0.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      Originally posted by NinjaTrader_Brett View Post
      Hello,

      Thanks for the note.

      The stop loss price is not changed by the ATMStrategyCreate() method. It is done by the ATM Strategy template. Also, you cannot have a stoploss of 0.

      Let me know if I can be of further assistance.
      Thanks Brett. But then why is there a StopLoss parameter in the ATMStrategyCreate() method? What does it do? And if that doesn't set the stoploss on the entry, is there any way to override the ATM Strategy's stoploss and do it in the strategy code at all?

      Comment


        #4
        Originally posted by cassb View Post
        Thanks Brett. But then why is there a StopLoss parameter in the ATMStrategyCreate() method? What does it do? And if that doesn't set the stoploss on the entry, is there any way to override the ATM Strategy's stoploss and do it in the strategy code at all?
        Bryan, that would be used if you enter by a Stop order then, it's not a StopLoss order parameter.

        It would use the default stoploss as saved in the AtmStrategyTemplate you call in AtmStrategyCreate(), you can change the stoploss later with the AtmStrategyChangeStopTarget method.

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Bryan, that would be used if you enter by a Stop order then, it's not a StopLoss order parameter.

          It would use the default stoploss as saved in the AtmStrategyTemplate you call in AtmStrategyCreate(), you can change the stoploss later with the AtmStrategyChangeStopTarget method.
          Aha -- OK, that makes sense then. Thank you!

          So if I want to set the initial stop of the strategy and then let the template handle the breakeven and trailing stop, I would use the AtmStrategyChangeStopTarget() method on the next OnBarUpdate() call to change the stoploss from whatever the template set it to?

          Comment


            #6
            Yes, that's correct - for an example using those methods you can check into the SampleAtmStrategy we ship per default with NT.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            671 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            379 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            111 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            575 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            582 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X