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 BarzTrading, Today, 07:25 AM
          2 responses
          14 views
          1 like
          Last Post BarzTrading  
          Started by devatechnologies, 04-14-2024, 02:58 PM
          3 responses
          19 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by tkaboris, Today, 08:01 AM
          0 responses
          3 views
          0 likes
          Last Post tkaboris  
          Started by EB Worx, 04-04-2023, 02:34 AM
          7 responses
          162 views
          0 likes
          Last Post VFI26
          by VFI26
           
          Started by Mizzouman1, Today, 07:35 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X