Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetStopLoss

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

    SetStopLoss

    Is this method always a closeout?

    For some reason, when I am entering two trades in the same stock

    (lets call them long1 and long2)...

    When the trigger for StopLoss on long2 (a dynamic Moving Average CrossBelow) occurs, my entire position is closed, including both

    -- long2 (which is correct)

    -- and long1 (which is wrong, this portion of the strategy has its own StopLoss price which is substantially lower).

    I have my Strategy UI set to "PerEntryExecution" so I am confused as to why this is happening.

    Thanks and regards,

    Andrew

    #2
    Hello Andrew,
    You need to refer to the order handling method and not the order submission methods to link the stops / target with the entry.

    Please assign a unique name while submitting the entry order and refer to that order name to your stop.

    For example if you are submitting the 2 entry order as

    Code:
    if (condition)
    {
       EnterLong("Long1");
    }
    if (condition 2)
    {
        EnterLong("Long2");
    }
    
    
    //and set the stop as
    SetStopLoss("Long1", CalculationMode.Ticks, 10, false);  //10 tick stop for Long1
    SetStopLoss("Long2", CalculationMode.Ticks, 15, false);   //15 ticks stop for Long2
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      TY Joydeep I have done this already here is the toy code.


      Entry 1:

      Code:
      if ((Closes[2][0] <= support * (1 + pricePremium)) 
      && (Closes[2][0] >= support)
      
      {
      
      EnterLongLimit(2, true, shareQuanity, (support * (1 + pricePremium)), "BuyLong1");
      
      SetProfitTarget("BuyLong1", CalculationMode.Price, (support * (1 + pricePremium)) + ProfitCalc);
      
      SetStopLoss("BuyLong1", CalculationMode.Price, (support * (1 + pricePremium)) - stopLossCalc, false);
      
      }


      Entry 2:

      Code:
      
      if(CrossAbove(Closes[2], movingAverage, BarsSinceEntry(2, "BuyLong2", 1))))	
      							
      {
      	EnterLong(shareQuantity, "BuyLong2");
      		
      
      
                    SetProfitTarget("BuyLong2", CalculationMode.Price, (support * (1 + pricePremium)) + ProfitCalc);
      								
                    SetStopLoss("BuyLong2", CalculationMode.Price, (movingAverage - 0.02), false);
      							
      }

      What have I missed?

      Comment


        #4
        Hello Andrew,
        The Set() method will work for orders submitted on the primary bar only.

        Since you are submitting the order on a secondary bar the Set() methods will not work as per your desire. In such scenario please use the Exit() methods.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        108 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        55 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        37 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        39 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        76 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X