Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple dinamic stoploss

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

    Simple dinamic stoploss

    Hello everyone,
    I can not write these simple code to manage a dynamic stoploss:

    condition market.position = long ----->
    if
    close is less than the value of a Ema[1]
    then
    close position to the next bar

    I can not use the CrossAbove () function because it does not accept the double type.

    can someone help me?

    thanks

    #2
    Hello,

    Thank you for your forum post and welcome to the NinjaTrader support forums.

    let me ask you a quick question first. Are you using SetStopLoss() for your stop or are you using ExitLong() for example to exit the position when this conditon becomes true.

    In this case you would not need to use CrossAbove(). You would just need to use > greater then sign.

    if(Position.MarketPosition == MarketPosition.Long)
    {
    if (Close[0] > EMA(14))
    ExitLong();
    }



    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      Thank you very much

      works perfectly

      I'm sorry it was too simple

      GOOD DAY BRETT



      Originally posted by NinjaTrader_Brett View Post
      Hello,

      Thank you for your forum post and welcome to the NinjaTrader support forums.

      let me ask you a quick question first. Are you using SetStopLoss() for your stop or are you using ExitLong() for example to exit the position when this conditon becomes true.

      In this case you would not need to use CrossAbove(). You would just need to use > greater then sign.

      if(Position.MarketPosition == MarketPosition.Long)
      {
      if (Close[0] > EMA(14))
      ExitLong();
      }



      Let me know if I can be of further assistance.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      589 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      342 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      555 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      552 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X