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:	985
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

    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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      62 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      134 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X