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

Altered trailing stop in Strategy Builder -- need help

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

    Altered trailing stop in Strategy Builder -- need help

    Hello,

    I'm trying to incorporate a trailing stop into my strategy that always sits at the open of the previous candle, so long as it closes further into profit, if it doesn't I want the trail function to ignore it until the next profit candle.


    so for example:

    Trade enter Long -- stop loss @ low of entry candle
    Next bar closes higher -- stop loss moves from entry candle low to new bar open
    Third bar closes lower (but doesn't hit SL) -- stop loss is unaffected (because candle didn't close in the trade direction)

    My question is, is it possible to program something like this in the strategy builder? if not, how would this be coded manually?

    Thanks for any help you can offer.

    Below is a visual representation of this from the entry to where the trade was stopped out.

    Click image for larger version

Name:	StopLossExample.PNG
Views:	913
Size:	6.7 KB
ID:	1079146

    #2
    Hello lunardiplomacy,

    Thanks for your post.

    When creating logic to control an auto trail in the Strategy Builder, we must remember that the stop loss must be submitted on each bar in order to keep the order alive.

    You would set up a variable to control when you should submit the stop loss to the initial level, and to submit the stop loss to your AutoTrail price level. In this case, you would have a condition to submit the stop loss to the initial level when a "Stop Loss Mode" variable is 0, and then to submit it to the the AutoTrail level when "Stop Loss Mode" is 1. For the AutoTrail condition, I would recommend using another variable for where the stop loss should be placed, and then you can have another condition that updates this variable to Open[1] (the open of the previous bar.)

    I have attached an example strategy that can demonstrate controlling your stop loss in the Conditions and Actions page of the Strategy Builder following your own logic. You could take the advised modifications above to accomplish your goal, but I would recommend first to understand how the strategy is managing the stop loss so you can create strategies following this approach on your own.

    If you would like to update the stop loss programmatically in unlocked code, I recommend following our SamplePriceModification example.

    SamplePriceModification - https://ninjatrader.com/support/help...of_stop_lo.htm

    I look forward to being of further assistance.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Jim,

      Much appreciated, this appears to be quite comprehensive. I'll need to comb through it for a bit before I completely understand what it's doing. I'll let you know if there is anything I don't grasp or if I have trouble implementing. Otherwise, thank you for your help and speedy reply.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Aviram Y, Today, 05:29 AM
      0 responses
      3 views
      0 likes
      Last Post Aviram Y  
      Started by quantismo, 04-17-2024, 05:13 PM
      3 responses
      27 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by ScottWalsh, 04-16-2024, 04:29 PM
      7 responses
      35 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by cls71, Today, 04:45 AM
      0 responses
      6 views
      0 likes
      Last Post cls71
      by cls71
       
      Started by mjairg, 07-20-2023, 11:57 PM
      3 responses
      218 views
      1 like
      Last Post PaulMohn  
      Working...
      X