Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order of the execution of several orders in the same bar

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

    Order of the execution of several orders in the same bar

    Hello,

    I have problems with how orders are executed in NinjaTrader on backtesting. Here is the situation.

    My strategy works with 60 minutes bars and it uses unmanaged orders. Since it is pretty dificult to explain the situation I attach an image that clearifies the situation.

    The orders that are executed in the 13:00 bar are:
    - A Buy/Stop order as a stopLoss for the short position entered in the previous bar and using 130.99 as the stop price.
    - A Buy/Stop order to enter Long with stop in 131.04.

    Well, that bar opens below both stopPrices and closes over them, so the reasonable order for executing those orders would be: first de Stoploss at 130.99 and after this one the enterLong at 131.04; but, as you can see in the image, the order applied is the contrary.

    I think that the problem is that when backtesting, NT executes the orders following the order in what they are written in the code instead of applying a more logical approach... ¿Is this the problem? ¿How can I solve it in an easy way?

    Thanks in advance.

    P.S: It was hard to me to explain the problem so wether something is not clear, please ask me and I'll try to explain myself in a better way.
    Attached Files

    #2
    sagoga69, please enable TraceOrders in your strategy and then rerun the backtest to see the exact sequence taking place, you might need to test with more granularity added here for your scenario.



    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by

    Comment


      #3
      Thank you very much, Bertrand. The multitimeframe worked perfect.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X