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

Stop Losses

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

    Stop Losses

    Hi everyone
    I want to apply a stop loss using the ATR(14).
    I wrote the following code:
    // Condition set Long Stop Loss
    if (Close[0] < (Position.AvgPrice - ATR(14)[0])
    && Position.MarketPosition == MarketPosition.Long)
    {
    ExitLong(
    "STOPLOSS", "BUY");
    }

    Problem is, the stop loss never kicks in!

    Any advice?

    Thank you

    #2
    Hi Stefy,

    Is "BUY" the same "fromentrysignal" used in the EnterLong() function? If not, that would cause the problem you are seeing...

    Comment


      #3
      Originally posted by Gumphrie View Post
      Hi Stefy,

      Is "BUY" the same "fromentrysignal" used in the EnterLong() function? If not, that would cause the problem you are seeing...
      Thank you, Gumphrie! That was the problem indeed.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Patlpp, 08-16-2021, 03:10 PM
      10 responses
      498 views
      0 likes
      Last Post Joerg
      by Joerg
       
      Started by AdamDJ8, 05-07-2024, 09:18 PM
      2 responses
      17 views
      0 likes
      Last Post -=Edge=-  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      46 responses
      4,101 views
      3 likes
      Last Post tradgrad  
      Started by usasugardefender, Today, 01:42 AM
      0 responses
      1 view
      0 likes
      Last Post usasugardefender  
      Started by haas88, 03-21-2024, 02:22 AM
      15 responses
      182 views
      0 likes
      Last Post haas88
      by haas88
       
      Working...
      X