Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trying to Close an ATM strategy

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

    Trying to Close an ATM strategy

    Hi,

    I just noticed on some strategies using ATM that when using AtmStrategyClose to cancel all orders and go flat it is not working as expected.
    If the ATM has not yet a position it works fine, but if it has a position with targets and stops ( ie; no orderId active but atmstrategy id is active ) then AtmStrategyClose removes all orders but reverses position ?

    I tried reducing my code to the minimun and adding a condition to exit if trade lasts for more than 3 bars ;

    if(atmStrategyId.Length !=0 && orderId.Length == 0 && (CurrentBar-entrybar)>=3) AtmStrategyClose(atmStrategyId);

    ..and still the same, cancel orders, close position, start a new inverse and naked position...

    Am I doing something wrong ?

    Thanks !
    pmaglio
    NinjaTrader Ecosystem Vendor - The Indicator Store

    #2
    pmaglio, are you sure the close algorithm is only called once and not multiple times actually? As otherwise you could end up in a unwanted position as the closing of the open position could take a few moments and in the meantime another call to 'close' could be triggered...this would be the same as hitting the close button for example more than once in manual trading.

    Comment


      #3
      You were right Bertrand, making this small change to run AtmStrategyClose only once solved the issue.
      if(atmStrategyId.Length !=0 && orderId.Length == 0 && (CurrentBar-entrybar)>=3 && onlyonce== false)
      {
      AtmStrategyClose(atmStrategyId);
      onlyonce=
      true;
      }
      Thanks !
      pmaglio
      NinjaTrader Ecosystem Vendor - The Indicator Store

      Comment


        #4
        You're welcome, glad to hear you could resolve the issue.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 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