Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

    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 RookieTrader, Today, 07:41 AM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by kujista, Today, 05:44 AM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by elderan, Yesterday, 08:03 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by samish18, Yesterday, 08:57 AM
      8 responses
      25 views
      0 likes
      Last Post samish18  
      Started by DJ888, 04-16-2024, 06:09 PM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_Erick  
      Working...
      X