Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATM strategy closing position prematurely

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

    ATM strategy closing position prematurely

    Hi guys I have an odd one and would appreciate some help. I am using an ATM strategy and changing the stops and targets. The stop is an ATR stop which works fine.

    The problem is if I take say a long trade and add the second part of the code that changes the target it changes the target to below the price where the ATR stop is located and closes out target1 leaving target 2 still working, Any idea on what I'm doing wrong here? It should reset the target to +70 ticks over the entry price so no idea why it is changing it to where the ATR stop is located. Thanks. DJ


    if (atmStrategyId1.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId1) != Cbi.MarketPosition.Flat)
    {
    AtmStrategyChangeStopTarget(0, ATR, "STOP1", atmStrategyId1);
    AtmStrategyChangeStopTarget(Position.AvgPrice+70*T ickSize,0, "TARGET1", atmStrategyId1);

    }

    #2
    Hello,

    Can you please provide more of the code? I'd like to see the values you are using for ATMStrategyCreate and where this is to relation in OnBarUpdate to your ATMStrategyChange.

    I'd also suggest adding some Print() statements or DrawLine() for some of the values you are using for the stops and targets to help determine where these are being placed.

    Click here for more information on Debugging NinjaScript Code
    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    153 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    71 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    125 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    79 views
    0 likes
    Last Post PaulMohn  
    Working...
    X