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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      134 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      75 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      119 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      114 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      92 views
      0 likes
      Last Post CarlTrading  
      Working...
      X