Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Close ATM strategy in priority to stop loss generated by AtmStrategyCreate

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

    Close ATM strategy in priority to stop loss generated by AtmStrategyCreate

    // Condition set 1
    if (orderId.Length == 0 && atmStrategyId.Length == 0 && CrossAbove(Close[1]etc.))
    {
    atmStrategyId = GetAtmStrategyUniqueId();
    orderId = GetAtmStrategyUniqueId();
    AtmStrategyCreate(Action.Buy, OrderType.Limit, 0, 0, TimeInForce.Day, orderId, "MY-ATM", atmStrategyId);
    }
    So i have a stop on my Dom with that code.

    But if i want to put another priority condition > to my stop loss generated on the Dom to close my strategy, do i have to put :

    // Condition set 2
    if (Close[1] < MyIndicator(...))
    {
    AtmStrategyClose("idValue");
    Is that right, or i need to add another code ?

    thanks

    #2
    That will indeed close the active ATM strategy, but you need to use proper AtmStrategyId in that parameter.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Josh,

      But how can i get previous AtmStrategyId from previous "AtmStrategyCreate" and put in AtmStrategyClose("HERE");?

      Thanks for your help !

      Comment


        #4
        Originally posted by boulbi View Post
        Thanks Josh,

        But how can i get previous AtmStrategyId from previous "AtmStrategyCreate" and put in AtmStrategyClose("HERE");?

        Thanks for your help !
        When you call the ...Create() method, you pass in an id value thus you would need to hold onto this value in your script. Create a variable outside of OnBarUpdate() in the "variables" section. Check out the SampleAtmStrategy, it does exactly this.
        RayNinjaTrader Customer Service

        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