• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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:	248
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 Benjaminf, Today, 02:21 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Kate  
      Started by grayfrog, 05-24-2020, 09:29 PM
      5 responses
      31 views
      0 likes
      Last Post NinjaTrader_RyanS  
      Started by chrismcdermut, Today, 01:46 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Kate  
      Started by dpolyakov, Today, 01:13 PM
      3 responses
      14 views
      0 likes
      Last Post dpolyakov  
      Started by tjendra, Today, 12:15 PM
      3 responses
      10 views
      0 likes
      Last Post tjendra
      by tjendra
       
      Working...
      X