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

Clarifying SetTrailStop()

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

    Clarifying SetTrailStop()


    Hi there, I need assistance understanding SetTrailStop() behavoir. Unfortunately, the documentation is a little thin. Say I have:

    if (State == State.Configure)
    {
    SetTrailStop(CalculationMode.Ticks, 4);
    }


    Now, I do EnterLong(), and get in at 100 ticks.

    A) The market goes does to 96 ticks. Am I stopped out?
    B) The market goes up to 104 ticks. Does then stop then move to break even at 100 ticks?
    C) The market then goes up to 105 ticks. Does the stop then move to 101 ticks?

    Thanks,



    #2
    In my experience of using it the answer to all three questions is Yes. One odd behavior I have seen is that although the trailing stop adjusts tick-by-tick, as you would expect, it will sometimes immediately adjust relative to the extreme of the bar even though that is in the past. So following your example, you enter at 100 but the high of the current bar is 104; the stop immediately adjusts to 100 and you are right back out.

    Comment


      #3
      Hello timmbbo,

      Thanks for your post.

      Your concept of the trailing stop is correct.

      When using the SetTrailStop() please pay attention to this note in the help guide: "Trail stop orders are modified based on the strategies 'Calculate' settings. In the case of 'Calculate' on bar close, when the bar closes the trail stop order modification will occur using the lowest/highest price of the bar as the reference price to apply the trail offset. Subsequently if the open price of the next bar is significantly higher or lower than this price then there is a possibility that the calculated trail stop price is now an invalid stop price. This is a risk with modifying any stop order closer to the current market price since any modification above/below the current price would be rejected." https://ninjatrader.com/support/help...ttrailstop.htm
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_PaulH View Post
        When using the SetTrailStop() please pay attention to this note in the help guide: [I]"Trail stop orders are modified based on the strategies 'Calculate' settings. In the case of 'Calculate' on bar close, when the bar closes the trail stop order modification will occur using the lowest/highest price of the bar as the reference price to apply the trail offset.
        Paul, thanks for your response. I'm still a little confused. The calculation modes are:

        •CalculationMode.Percent
        •CalculationMode.Ticks
        •CalculationMode.Pips

        Therefore, appears to be no "'Calculate' on bar close". Am I missing something, or is this just a case of poor docs? Thanks

        Comment


          #5
          Hello timmbbo,

          Thanks for your post.

          The Calculate setting of the strategy is not the same thing as the CalculateMode of the stop loss.

          The CalculateMode describes to the SetTrailStop() method what the initial stop should be set based on the selection and the value provided. IE set the stop at 1 %, set at 10 ticks, set at 3 pips.

          The Calculate setting refers to how often the OnBarUpdate() is called (which means how often the strategy script is run) and this is what the help guide "note" refers to.
          Reference: https://ninjatrader.com/support/help...?calculate.htm
          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Jon17, Today, 04:33 PM
          0 responses
          1 view
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          4 views
          0 likes
          Last Post Javierw.ok  
          Started by timmbbo, Today, 08:59 AM
          2 responses
          10 views
          0 likes
          Last Post bltdavid  
          Started by alifarahani, Today, 09:40 AM
          6 responses
          41 views
          0 likes
          Last Post alifarahani  
          Started by Waxavi, Today, 02:10 AM
          1 response
          20 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Working...
          X