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 bortz, 11-06-2023, 08:04 AM
              47 responses
              1,607 views
              0 likes
              Last Post aligator  
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              9 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              19 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              6 views
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              16 views
              0 likes
              Last Post Javierw.ok  
              Working...
              X