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 Loss Alternative

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

    Stop Loss Alternative

    I don't want to use SetStopLoss because when my strategy gets to a certain point, I don't just simply want to exit or reverse the position. I have tried numerous things such as.....

    if (Position.MarketPosition == MarketPosition.Long
    && Position.MarketPosition == Position.AvgPrice - 10 * TickSize)

    {
    EnterShort(2, "Short2");
    }

    This gives me an error message when I compile it. Any suggestions how I can make this happen without using the SetStopLoss???

    #2
    You would need to check for price (represented here by Close[0]) being greater or equal to your reversal tick amount, so this below should compile well, you would need to test if it's acting to your expectations -


    if
    (Position.MarketPosition == MarketPosition.Long && Close[0] >= Position.AvgPrice - 10 * TickSize)
    {
    EnterShort(
    2, "Short2");
    }

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks Bertrand.....but that would wait until the close of the bar which could result in a much larger loss! Is replacing "Close" with "Low" the only alternative????

      Comment


        #4
        In realtime you could just let this bit of code run with CalculateOnBarClose = false, so it would trigger intrabar and does not wait for the bar penetrating to close fully.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Oh yeah.....good point! Thanks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Barry Milan, Today, 10:35 PM
          0 responses
          2 views
          0 likes
          Last Post Barry Milan  
          Started by DJ888, Yesterday, 06:09 PM
          2 responses
          9 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          40 views
          0 likes
          Last Post jeronymite  
          Started by bill2023, Today, 08:51 AM
          2 responses
          16 views
          0 likes
          Last Post bill2023  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          167 responses
          2,260 views
          0 likes
          Last Post jeronymite  
          Working...
          X