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