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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    72 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    44 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    26 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    31 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    61 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X