Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Avoid same bar execution

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

    Avoid same bar execution

    How do I avoid same bar execution by scripting? Attached an Image of what I'm meaning.
    This affect only backtest and past trades, during rt trading I think this should be ok


    Thanks in advance for your suggestions

    Attached Files

    #2
    imported post

    The only way to do this is by managing your exit orders through Exit() methods and not SetStopLoss() or SetProfitTarget() and run with CalculateOnBarClose true or widening your stop/target prices on the 1st bar of a positon and then tightenting it on the next bar.

    The reason is that SetStopLoss() related methods will make the order go live on the same bar that the position is opened. If the stop/target price is within the range of this bar, you get executed as you are reporting.

    If you use an exit method, orders generated are executed on the following bar after a position has been opened.

    Ray

    RayNinjaTrader Customer Service

    Comment


      #3
      imported post

      ok thanks for your suggestion

      Marce

      Comment


        #4
        Originally posted by NinjaTrader_Ray View Post
        The reason is that SetStopLoss() related methods will make the order go live on the same bar that the position is opened. If the stop/target price is within the range of this bar, you get executed as you are reporting.
        Hi, is there a way I can force the stop order to go live only on the next bar after entry (disallow same bar entry/exit).

        BTW I am using NT7 and came across this thread by googling. I see many beginners struggle with the same problem of same bar entry/exit by the no. of threads discussing this.

        Comment


          #5
          Sachin,

          I am happy to assist you.

          Please follow Ray's recommendation. Essentially he is saying you can SetStopLoss() to something very low, then reset it to what you want the next bar. Otherwise, you can monitor your own stop loss in your strategy by using Exit() methods.

          For more information on SetStopLoss(), please see the link below.



          For more information on order methods (such as ExitLong()), please see the link below.



          For more information on managing stop-losses and take-profits, please see the following reference sample.



          Please let me know if I may assist further.
          Adam P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          650 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          577 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X