Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Confused on Dynamically resetting Stop Loss

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

    Confused on Dynamically resetting Stop Loss


    I'm confused on how to dynamically reset a stop loss.for an active position.

    In my code, I'm trying to code a trailing stop. I'm using SetStopLoss(CalculationMode.Price). In the help section:



    I read:

    "You may call this method from within the strategy OnBarUpdate() method should you wish to dynamically change the stop loss price while in an open position"

    but the next bullet point says,

    "Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price / offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position​"

    This seems contradictory. I only want to reset my StopLoss when I'm in an active (open) position, which the first point says I can do, but the next point says I need to be flat?

    How can I dynamically reset a stop loss and profit target to implement a trailing stop? Thanks,






    #2
    Hello timmbbo,

    Thanks for your post.

    This note in the help guide means that the stop loss should be reset when you are in a flat position. If you do not reset the stop loss when the strategy is flat, the last price/offset value set would be used to generate your stop loss order on the next position.

    Here is a reference sample that demonstrates resetting a stop loss when a strategy is in a flat position and dynamically calling Set methods in OnBarUpdate().

    SamplePriceModification: https://ninjatrader.com/support/help...of_stop_lo.htm
    <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
      > Here is a reference sample that demonstrates resetting a stop loss when a strategy is in a flat position

      Thanks. I'm very interested in how to reset a stop loss when I'm in an open position. Say I have:

      SetStopLoss(50 ticks)
      SetProfitTarget(100 ticks)
      EnterLong()

      After a bit, I have a 50 tick gain. Now, I want to reset my stop loss to break even. Since I'm in a long position, how to do? Thanks


      Last edited by timmbbo; 04-14-2024, 09:48 PM.

      Comment


        #4
        Hello timmbbo,

        Thanks for your notes.

        A stop loss/profit target should be reset when you are in a flat market position as noted in the help guide.

        From the help guide: "Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price / offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position​"

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

        Please review the reference sample from the help guide linked in post # 2.

        This reference sample demonstrates submitting a stop loss and profit target order using default values offset from your entry order average fill price. It also demonstrates modification of the stop loss order to a break even price once a desired level of profit has been reached.

        I have also provided a link to the help guide reference sample here: https://ninjatrader.com/support/help...of_stop_lo.htm
        <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

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        59 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        74 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X