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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      182 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      335 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      259 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      358 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      188 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X