Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

breakeven

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

    breakeven

    good day, please tell me how to make breakeven in my script if I use limit orders.
    I tried to use this

    #region DynamicTrail()
    private void DynamicTrail()
    {
    if (Position.MarketPosition == MarketPosition.Long && N_BU > 0)
    {
    // Raise stop loss to breakeven when there is at least N_BU ticks in profit
    if (Close[0] >= Position.AvgPrice + N_BU * TickSize)
    {
    double new_sl=Position.AvgPrice + 1 * TickSize;
    SetStopLoss(CalculationMode.Price, new_sl);
    //Print("Переставили SL new_SL=" + new_sl);
    }
    }

    if (Position.MarketPosition == MarketPosition.Short && N_BU > 0)
    {
    // Raise stop loss to breakeven when there is at least N_BU ticks in profit
    if (Close[0] <= Position.AvgPrice - N_BU * TickSize)
    {
    double new_sl=Position.AvgPrice - 1 * TickSize;
    SetStopLoss(CalculationMode.Price, new_sl);
    //Print("Переставили SL new_SL = " + new_sl);
    }
    }
    }


    #endregion

    but it didn't work

    #2
    Hello Papercut110,

    Attached I am including an example of a break even movement in a script created with the Strategy Wizard.

    Also, below I am including a link to a unlocked script that demonstrates a more advanced set of break even movements as well as a custom trailing stop type of movement I've named CustomStopStrategyWithTrailExample.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you, Chelsea!)

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X