Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Breakeven for trade 1 after profit target is hit for trade 2 is hit

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

    Breakeven for trade 1 after profit target is hit for trade 2 is hit

    Hello,

    I have looked at all the code examples found through others post but what i am looking to code is slightly different, so I am hoping it is not too difficult for me to do myself.

    If I have two trades going. I have set ticks I would like to exit for profit target and stop loss. My goal is to test and see how it would impact my strategy by adding this piece of breakeven in to see if has any true value.
    Both: Enter off the same entry
    Trade 1: Exits 160 ticks profit or 65 ticks stop loss
    Trade 2: Exits 40 ticks profit or 65 ticks stop loss

    This is the logic I am thinking: If Trade 1 is in trade and trade 2 has exited trade only through its profit target, move the stop loss of trade 1 to average position price + 2 ticks.

    Any insight would be greatly appreciated. If this could cause issues in an automated code, I might just have to forget it.

    #2
    Hello durdcash,

    Thanks for your post.

    You could consider detecting when the order you want to know was hit is filled and then implementing your breakeven logic in OnExecutionUpdate() to change the price of your stop loss.

    You could track what price the first profit target order is submitted to within a variable, create a condition to check and see if the current Close price is greater than that variable, and add your breakeven logic within that condition to move the stop loss.

    See the reference sample linked below from the NinjaTrader help guide demonstrating using OnOrderUpdate() and OnExecutionUpdate() methods to submit protective orders.

    https://ninjatrader.com/support/help...and_onexec.htm

    And, see the help guide documentation below.
    OnExecutionUpdate: https://ninjatrader.com/support/help...tionupdate.htm
    OnOrderUpdate: https://ninjatrader.com/support/help...rderupdate.htm

    Let me know if I 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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    134 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X