Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Based On Close of Entry Candle

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

    Stop Based On Close of Entry Candle

    Strategy optimization and walk-forward testing is how I determine my best Stop value for Live auto-trading. In the real world we have Slippage which can result in being stopped out of what could otherwise have been a very big gain.

    This isn't new so I searched but could not find anything on how to Set the Stop in a Stratgey based on the Closing price of the Entry bar, rather than from the trade's actual entry price?

    Example:
    Closing price of 5 min entry candle is 100
    Actual entry price, due to slippage, is 98

    Normal Ninja Stop entry:
    If I have a Stop of 2 points on a Long entry and the actual Entry price for the trade at close of 5 min entry bar is 98, my strategy would place the Stop at 96

    New Stop entry:
    If I have a Stop of 2 points on a Long entry and the Closing price for the 5 min entry bar is 100, my strategy would place the Stop at 98

    Any help would be greatly appreciated.

    Dan

    #2
    Hi Dan, are you working in the Strategy Wizard or in the NinjaScript editor to create your strategies?

    Comment


      #3
      Ninja Script. I originally wrote the Strat in the Wizard, but had to unlock it to add some other things.

      Comment


        #4
        Hi Dan, ok have you tried saving the close price of your entry bar to a variable and then using SetStopLoss set to price? Please see this link here - http://www.ninjatrader-support.com/H...tStopLoss.html

        Here's a link to a reference sample that might help you - http://www.ninjatrader-support2.com/...ead.php?t=3222

        Comment


          #5
          Bertrand

          Thanks for the links. I will take a look at them and see if I can find a nice way to do it.

          Comment


            #6
            Bertrand

            I'm still not sure how to save the closing price of my entry bar to a variable? Any other help would be appreciated and/or let me know if you need to see any part of my code.

            Comment


              #7
              As an Action you want to expand the Misc section. Select the "set user defined variable" one. From there select Variable0 and then select the Close price.
              Josh P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              558 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              324 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              545 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              547 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X