Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question about trail stop

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

    Question about trail stop

    Hi,
    I currently have a strategy that sets a default profit taker and a stop loss.

    I want to be able to disable/enable a trail stop.

    I read on the help section that the SetTrailStop() method can NOT be used concurrently with the SetStopLoss() method for the same position.

    What will happen if I have a trailstop on 5 ticks behind on a position that is Long, and that position starts to move negative from the very first moment? Wouldnt that trail stop follow backwards with the same offset...if the negative move is smooth or it will be limited to -5

    #2
    Hi nikolaalx,

    That is correct, if SetStopLoss is used in your script, SetTrailStop will no longer work.

    The trail stop does not move backwards. If the price goes in the direction of the trade, the trail will follow tick for tick. If the price goes against the trade, the trailing stop will not move.

    Once SetStopLoss or SetTrailStop has been called, it is not possible to cancel this. If you are wanting to be able to cancel a stop or target, you will need to use custom orders to do this instead of SetStopLoss or SetTrailStop.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I can set a default trail stop then which would be equal to the static stop loss that I used to have.

      Then I can add a condition that would modify that initial trail stop with a much smaller tick based trail offset upon a certain profit movement.

      Here is what I have compiled. I am a complete newbie in C, which is why I will appreciate any feedback.


      if (Position.MarketPosition == MarketPosition.Flat)
      {
      SetTrailStop("", CalculationMode.Percent, StopLoss, false);
      }


      else if (Position.MarketPosition == MarketPosition.Long)
      {
      if (Close[0] > Position.AvgPrice + StopEvenOffset * TickSize)
      {
      SetTrailStop("", CalculationMode.Ticks, TrailStop, false);
      }
      }

      Comment


        #4
        Hi nikolaalx,

        I imagine that would work, but do keep in mind that the trailing will start as soon as the position is taken and will be using the StopLoss variable amount until the next bar closes. On the next bar close, then the trail will be set to the TrailStop amount.

        You could also use a stop loss and modify it in OnBarUpdate. There is a sample that does something like this.
        http://www.ninjatrader.com/support/f...ead.php?t=7499
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        633 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        567 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X