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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        50 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        16 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        22 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        23 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X