Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Loss Won't Hold at Breakeven

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

    Stop Loss Won't Hold at Breakeven

    Hi everyone,
    I have an issue: when the stop loss moves to breakeven using ChangeOrder, with the main condition Close[0] <= priceMove, everything works fine... until the price closes above priceMove. At that point, the stop loss reverts to its original position (stopLoss). What can I do to ensure the stop loss stays at breakevenPrice, even if the price moves back above? I just need it to move once when the price crosses below priceMove.​

    Is this normal happen with ChangeOrder? I am using calculate onbarclose, for that reason I guess "jump" the condition, any idea how to fix it meanwhile I use onbarclose? its necessary to the strategy

    Code:
         stopOrder = ExitShortStopMarket(0, true, Convert.ToInt32(QTY1), stopLoss, "SL", "ShortEntry1");
    
                    double breakevenPrice = Position.AveragePrice - (10 / tickValue) * TickSize;
                    double priceMove = Position.AveragePrice - (50 / tickValue) * TickSize;
    
                    if (stopOrder != null
                        && stopOrder.StopPrice > Position.AveragePrice
                        && Close[0] <= priceMove)
                    {
                        ChangeOrder(stopOrder, Convert.ToInt32(1), 0, breakevenPrice
                        );
                    }​

    #2
    Hi everyone,

    So I found a way to keep using OnBarClose but also move to breakeven without get back to the stop loss...

    You dont use ChangeOrder(), you need tu use CancelOrder()... so you cancel the stop loss and make new ones orders in the breakeven price.

    I recommened first at all make the news orders and then cancel the old ones

    Comment


      #3
      Hello FaaZer,

      See the forum thread below where this is recently discussed.


      Below is a link to examples of custom stop behavior.


      Submit the order with isLiveUntilCancelled as true from OnExecutionUpdate(). When the condition to trigger the breakeven occurs, use logic to only call this once.

      Model the code after the ProfitCasestopTrailExitOrdersExample.
      In OnBarUpdate() change
      'Close[0] > currentSlPrice + StopLossDistance * tickSizeSecondary'
      to
      'Close[0] > Position.AveragePrice + StopLossDistance * tickSizeSecondary'
      and change
      'currentSlPrice = Close[0] - StopLossDistance * tickSizeSecondary;'
      to
      'currentSlPrice = Position.AveragePrice;

      This would set the stop price to the entry price once, after the close is StopLossDistance amount of ticks above the entry price.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      116 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      61 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      40 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      43 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      82 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X