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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        72 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        39 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        63 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        63 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X