Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

reset the trail stop on strategy

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

    reset the trail stop on strategy

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

    In my strategy, the trailing stop is on bar uptade. I do not understand this tip.

    - For example. I have used
    SetTrailStop (CalculationMode.Percent, 0.01);

    The value of 0.01 can be modified? one example:

    In NQ instrument. Long Order filled at 10000
    Trail stop offset 9900
    Next order Long Order filled at 9900
    Trail stop offset 9801

    This is the scheme?

    Regards

    #2
    Hello memonic,

    Thanks for your post.

    This tip from the SetTrailStop() help guide page means that in your strategy you would need to check if you are in a flat position (Position.MarketPosition == MarketPosition.Flat) and call SetTrailStop() to reset the stop loss to the original value when all positions are closed

    See the SamplePriceModification example script in the help guide documentation below for an example of modifying the price of stop loss and profit target orders.

    SamplePriceModification: https://ninjatrader.com/support/help...of_stop_lo.htm

    SetTrailStop(): https://ninjatrader.com/support/help...ttrailstop.htm

    Let us know if we 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
      Thanks Brandon.
      In the case of use train stop in flat position, the value of the offset is at triggered?. For example:

      if ((ToTime(Time[0]) > 230000 && ToTime(Time[0]) < 150000))
      SetTrailStop(CalculationMode.Percent, 0.001);

      The value of trail stop from 23.00 to 15.00 will be:
      Position.AveragePrice - Position.AveragePrice*0.001
      in the time window described above.

      Thanks in advance

      Comment


        #4
        Hello memonic,

        Thank you for your reply.

        Brandon is currently out of the office, however, I'm happy to answer.

        SetTrailStop would only be triggered if there is a position open for it to be protecting - if you are in a flat position it would not be active since there would be no position to protect.

        Please note in percentage calculation mode a value of 1 is equal to 100%, a value of 0.1 is equal to 10%, and a value of 0.01 will be 1%, so using 0.001 as the percent value would calculate a starting trail position of 0.1% of the average entry price.

        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Thanks kate for your answer.
          In this case trail stops works exactly with this two sentences:
          Case 1
          if ((ToTime(Time[0]) > 230000 && ToTime(Time[0]) < 150000))
          {
          if(Position.MarketPosition == MarketPosition.Long)
          {
          SetTrailStop(CalculationMode.Percent, stp2);
          }
          }

          case 2
          if ((ToTime(Time[0]) > 230000 && ToTime(Time[0]) < 150000))
          {
          SetTrailStop(CalculationMode.Percent, stp2);
          }
          In the backtest, on bar close, 12 minute bars. Case 1 and case 2 shows different results.

          Thanks.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          86 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          48 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          29 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          32 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          67 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X