Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How exactly is Market Order fills calculated during a backtest?

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

    How exactly is Market Order fills calculated during a backtest?

    I have a strategy which submits a market order at the close of a bar, but I often see the fill itself being above or below the actual close.

    So my question is, how does NT fill market orders in a backtest? What's the logic behind it?

    Thanks in advance.

    #2
    StockStalker, the Strategy Analyzer will fill market orders at the open of the next bar, not on the close. So for an example, if you have a cross over on bar 1, the code will pick it up on bar 2 and submit the orders, which will be filled at the open of bar 3.
    AustinNinjaTrader Customer Service

    Comment


      #3
      That's true, but I forgot to mention the strategy has multiple timeframes to achieve intrabar granularity (tick by tick chart + bar chart)

      So the strategy sees this bar closing and the next one open, and then submits a market order which gets filled intrabar via the tick by tick chart.

      So the question then is, how do market orders get filled when you have a tick-by-tick underlying chart like this?

      Comment


        #4
        StockStalker, if you want the order to be executed on the secondary series, you must submit it to that series (secondary bar series = bar index 1):
        Code:
        // EnterLong(int barsInProgressIndex, int quantity, string signalName)
        EnterLong(1, 1, "enter long one contract on the secondary series");
        AustinNinjaTrader Customer Service

        Comment


          #5
          Austin, thanks for the response. I understand what you're saying here, and I am aware of that.

          Let me rephrase my question...
          How does NT calculate Market order fills in a backtest on a 1-tick linechart?

          Comment


            #6
            Stock, the order is submitted to be filled on the open of the next bar update. For 1 tick charts, the open = high = low = close, so it would be filled at that tick price.

            OnBarUpdate() processes all bar series in chronological order, and if a timestamp is the same for two series, I believe it processes the lowest index first. This means the order will be filled at the next available OnBarUpdate() for the series you submitted it to.
            AustinNinjaTrader Customer Service

            Comment


              #7
              Austin, this makes sense

              Thanks for the help

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Mindset, 04-21-2026, 06:46 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by M4ndoo, 04-20-2026, 05:21 PM
              0 responses
              144 views
              0 likes
              Last Post M4ndoo
              by M4ndoo
               
              Started by M4ndoo, 04-19-2026, 05:54 PM
              0 responses
              71 views
              0 likes
              Last Post M4ndoo
              by M4ndoo
               
              Started by cmoran13, 04-16-2026, 01:02 PM
              0 responses
              125 views
              0 likes
              Last Post cmoran13  
              Started by PaulMohn, 04-10-2026, 11:11 AM
              0 responses
              79 views
              0 likes
              Last Post PaulMohn  
              Working...
              X