Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 LawrenHom, Today, 10:45 PM
        0 responses
        3 views
        0 likes
        Last Post LawrenHom  
        Started by love2code2trade, Yesterday, 01:45 PM
        4 responses
        28 views
        0 likes
        Last Post love2code2trade  
        Started by funk10101, Today, 09:43 PM
        0 responses
        7 views
        0 likes
        Last Post funk10101  
        Started by pkefal, 04-11-2024, 07:39 AM
        11 responses
        37 views
        0 likes
        Last Post jeronymite  
        Started by bill2023, Yesterday, 08:51 AM
        8 responses
        44 views
        0 likes
        Last Post bill2023  
        Working...
        X