Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Do I need to call SetStopLoss() for new position when the current position is closed?

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

    Do I need to call SetStopLoss() for new position when the current position is closed?

    Hello,

    In the SetStopLoss() documentation, it says "A stop loss order is automatically canceled if the managing position is closed by another strategy generated exit order", when an old position is closed and a new position is opened, do I need to call SetStopLoss() prior to the opening of new position in order to get the managed stop loss for the new position?

    Best,

    Billy

    #2
    Hello Billy,

    Thanks for your post.

    "A stop loss order is automatically canceled if the managing position is closed by another strategy generated exit order"

    An example of this would be if you called SetStopLoss() and SetProfitTarget() to place a stop loss and profit target order for an entry order and the SetProfitTarget() order was filled, the SetStopLoss() order would automatically be canceled since the entry order was filled by the SetProfitTarget() order.

    This happens because the SetProfitTarget() and SetStopLoss() methods prep NinjaTrader to submit a profit target order and stop loss order for the entry order that is submitted and these orders are tied together when submitted. Once either the profit target order or stop loss order is filled, the other Set method order is canceled.

    SetStopLoss(): https://ninjatrader.com/support/help...etstoploss.htm

    Please let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hello Brandon,

      Thank you for your email, I understand what you said. My question however is, if I start another new position and want the StopLoss and ProfitTarget again, do I need to call them again before my new position?

      Best,

      Billy

      Comment


        #4
        Hello Billy,

        Thanks for your note.

        Are you calling SetStopLoss() and SetProfitTarget() in OnStateChange() when the State == State.Configure?

        Or, are you calling the Set methods dynamically in OnBarUpdate()?

        If you are calling the Set methods in OnStateChange() when the State == State.Configure, the Set methods will automatically be applied to an entry order that is submitted when no FromEntrySignal property is defined. If a 'FromEntrySignal' property is defined, the Set methods will submit profit target and stop loss orders for the Entry order that has the same SignalName as the FromEntrySignal being used for the Set methods.

        If you are calling the Set methods dynamically in OnBarUpdate(), you would need to call the Set methods before the entry order method since the Set methods prep NinjaTrader to submit protective orders for that Entry.

        For example:

        //OnBarUpdate method
        SetProfitTarget(CalculationMode.Ticks, 10);
        SetStopLoss(CalculationMode.Ticks, 10);
        EnterLong();

        Let me know if I may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Thank you Brandon, you answered my question!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          52 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          130 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          70 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          43 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          47 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X