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

SetTrailStop not trailing?

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

    SetTrailStop not trailing?

    Hi,

    I've got a strategy that sets a trailing stop upon execution. The trailing stop does not trail the price though. After reading the helpfile, I believe it's because I've used SetTrailStop outside of OnBarUpdate. I had done this intentionally thinking the TrailStop would automatically trail.

    If I shift SetTrailStop inside of OnBarUpdate, does it place a new order / cancel previous order on every tick? If it does, does it know not to place the order if the tick is lower than the previous tick (for a long)?

    Thanks

    #2
    Hello peteM,

    Thanks for your note.

    The SetTrailStop method can be used in the Initialize() portion of the script as well as the OnBarUpdate portion of your script.

    When SetTrailStop is updated in OnBarUpdate the price of the initial stop market order is modified instead of being placed as a new order.

    Yes, SetTrailStop will not trail if you are long and the price falls.

    Below is a link to the help guide on SetTrailStop().
    http://www.ninjatrader.com/support/h...ttrailstop.htm


    Please let me know if I can be of further assistance.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by peteM View Post
      Hi,

      I've got a strategy that sets a trailing stop upon execution. The trailing stop does not trail the price though. After reading the helpfile, I believe it's because I've used SetTrailStop outside of OnBarUpdate. I had done this intentionally thinking the TrailStop would automatically trail.

      If I shift SetTrailStop inside of OnBarUpdate, does it place a new order / cancel previous order on every tick? If it does, does it know not to place the order if the tick is lower than the previous tick (for a long)?

      Thanks
      Where are you putting SetTrailStop()? If in Initialize(), then it should automatically be applied unchanged to every new order.

      If you do it in OBU, it will always be taken from the absolute current price as exists at the time that the order is reissued, with no reference to what may have happened in the past. If you want to reissue the order on favorable price movement, then you have to check for such before you reissue the order.

      Comment


        #4
        Originally posted by koganam View Post
        Where are you putting SetTrailStop()? If in Initialize(), then it should automatically be applied unchanged to every new order.

        If you do it in OBU, it will always be taken from the absolute current price as exists at the time that the order is reissued, with no reference to what may have happened in the past. If you want to reissue the order on favorable price movement, then you have to check for such before you reissue the order.
        I placed it under OnExecution(). I incorrectly though it would create problems if it was left under OBU. I still have to figure out how to amend the TrailStop like you mentioned a few days ago; probably work on that this weekend.

        I've just created a manual trailing stop for time being.

        Comment


          #5
          Hello peteM,

          In case you haven't already, I recommend you take a look at SamplePriceModification reference sample, to which I have linked below.
          http://ninjatrader.com/support/forum...ead.php?t=3222

          This uses SetStopLoss but the use of SetTrailStop is very similar. Keep in mind that you can only use one or the other per entry signal. If you use both, only the SetStopLoss will be activated.


          I hope this helps you in accomplishing your goal.

          Please don't hesitate to contact us for any other NinjaTrader inquiries you may have.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mestor, 03-10-2023, 01:50 AM
          16 responses
          388 views
          0 likes
          Last Post z.franck  
          Started by rtwave, 04-12-2024, 09:30 AM
          4 responses
          31 views
          0 likes
          Last Post rtwave
          by rtwave
           
          Started by yertle, Yesterday, 08:38 AM
          7 responses
          29 views
          0 likes
          Last Post yertle
          by yertle
           
          Started by bmartz, 03-12-2024, 06:12 AM
          2 responses
          22 views
          0 likes
          Last Post bmartz
          by bmartz
           
          Started by funk10101, Today, 12:02 AM
          0 responses
          7 views
          0 likes
          Last Post funk10101  
          Working...
          X