Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Breakeven in Strategy Builder Question

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

    Breakeven in Strategy Builder Question

    Hello all -

    I'm quite close to having a working breakeven/trailing stop script in strategy builder (borrowed heavily from NinjaTrader_ChelseaB's script which was super useful!) but I'm getting hung up in one place - I have a trigger price (BETriggerPrice) that moves the stoploss to breakeven, and then a second trigger price (Stops2ProfitPrice) to move the stoploss into profit - however, when testing on sim, if the last price goes above the second trigger level and then back below it, the stoploss jumps into profit, but then reverts back to the breakeven level, defeating the purpose of a trailing stop : )

    I'm attaching screengrabs of the strategy builder logic below - would appreciate any insight on how to make that stop-in-profit "stick" when the market price gets above the second trigger level - weirdly, the breakeven stop doesn't have this problem, but honestly I don't totally understand why...

    Thank you in advance!

    Click image for larger version  Name:	Screen Shot 2022-06-09 at 4.15.33 AM.png Views:	0 Size:	45.1 KB ID:	1204486Click image for larger version  Name:	Screen Shot 2022-06-09 at 4.15.45 AM.png Views:	0 Size:	36.1 KB ID:	1204487Click image for larger version  Name:	Screen Shot 2022-06-09 at 4.15.57 AM.png Views:	0 Size:	38.0 KB ID:	1204488Click image for larger version  Name:	Screen Shot 2022-06-09 at 4.16.11 AM.png Views:	0 Size:	31.4 KB ID:	1204489
    Attached Files
    Last edited by Daveman0; 06-08-2022, 08:24 PM.

    #2
    Hello Daveman0,

    Thank you for your reply.

    You're not checking the TriggerState in your conditions for each step, and I also don't see where you're setting TriggerState back to 0 when the position is flat in order to submit a new entry. So, in set 2 you'd want to add a condition that TriggerState = 1, in set 3 add a condition that TriggerState = 2, and then finally add a set that checks if the strategy position is flat and if so set TriggerState to 0 if you don't already have one.

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Originally posted by NinjaTrader_Kate View Post
      Hello Daveman0,

      Thank you for your reply.

      You're not checking the TriggerState in your conditions for each step, and I also don't see where you're setting TriggerState back to 0 when the position is flat in order to submit a new entry. So, in set 2 you'd want to add a condition that TriggerState = 1, in set 3 add a condition that TriggerState = 2, and then finally add a set that checks if the strategy position is flat and if so set TriggerState to 0 if you don't already have one.

      Please let us know if we may be of further assistance to you.
      Brilliant, thank you Kate, works perfectly! Much appreciated -

      Comment


        #4
        Originally posted by NinjaTrader_Kate View Post
        Hello Daveman0,

        Thank you for your reply.

        You're not checking the TriggerState in your conditions for each step, and I also don't see where you're setting TriggerState back to 0 when the position is flat in order to submit a new entry. So, in set 2 you'd want to add a condition that TriggerState = 1, in set 3 add a condition that TriggerState = 2, and then finally add a set that checks if the strategy position is flat and if so set TriggerState to 0 if you don't already have one.

        Please let us know if we may be of further assistance to you.
        Good evening,
        I'm new to the NinjaTrader platform and I'm looking into putting together a BE strategy similar to this. In my brain, for setting a SL for a long order, shouldn't I need to subtract a price from the average position price? Then add to that as the SL moves up with the trade?... with the opposite for a short?

        Thank you!
        dez

        Comment


          #5
          Hello dezaster,

          Thanks for your note.

          You can use exit order methods and adding coding logic in the Strategy Builder to accomplish this goal.

          Please note that you would not be able to use the exit methods and the stops in the stop and targets window as that creates a violation of the managed approach internal order handling rules, linked here: https://ninjatrader.com/support/help...d_approach.htm

          My colleague Chelsea has created educational examples of strategy builder breakeven and trailing stop in the strategy builder here:
          https://ninjatrader.com/support/foru...der#post806596

          Please let us know if we may assist further.​
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          71 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          143 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          76 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          47 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          51 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X