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

Moving stop to breakeven after first profit target then changing stop to trailing

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

    Moving stop to breakeven after first profit target then changing stop to trailing

    Hi,

    I am coding a strategy in the editor and I want to have an exit strategy whereby after the first profit target is reached the stop moves to breakeven, I then want to change the stop type from a static stop to a trail stop.

    Using the SamplePriceModification strategy on the Ninjatrader documentation for modifying the price of stop loss and profit target orders (https://ninjatrader.com/support/help...of_stop_lo.htm) I am able to complete the first part (move stop to breakeven once first profit target is hit) but I don't know how to change the order to a trail stop.

    Can you help?

    Thanks,

    Neil

    #2
    Hello Neil,

    Thanks for your post.

    With the Set methods, you cannot use both a trailing stop and a set stop in the same entry order, the trailing stop would be ignored.

    You can use your own logic to create a trailing stop with the SetStopLoss(). You would need to add a few bool variables to control the logic flow. For example, once you have moved the stop to breakeven you would set a bool variable so that it cannot be moved to breakeven again (until the bool is reset), then your logic could again compare the current price to some trail value and adjust the set stop to that next level.

    You may want to download and review an example of a trailing stop by NinjaTrader_Chelsea in this thread: https://ninjatrader.com/support/foru...ing#post802269 Look specifically for the ProfitChaseTrailSetMethodsExample.
    Last edited by NinjaTrader_PaulH; 09-16-2021, 01:22 PM. Reason: Replaced link
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi NinjaTrader_PaulH - thanks for the reply, however the link you posted doesn't take me to Chelsea's example - it links back to this post.

      Can you resubmit the post?

      Comment


        #4
        Hello Neil,

        Thanks for your reply.

        I have corrected the link in post #2.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        26 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, Yesterday, 09:53 PM
        2 responses
        49 views
        0 likes
        Last Post wzgy0920  
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        192 views
        0 likes
        Last Post Hasadafa  
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,234 views
        0 likes
        Last Post xiinteractive  
        Working...
        X