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 strategist007, Today, 07:51 PM
              0 responses
              2 views
              0 likes
              Last Post strategist007  
              Started by StockTrader88, 03-06-2021, 08:58 AM
              44 responses
              3,967 views
              3 likes
              Last Post jhudas88  
              Started by rbeckmann05, Today, 06:48 PM
              0 responses
              4 views
              0 likes
              Last Post rbeckmann05  
              Started by rhyminkevin, Today, 04:58 PM
              4 responses
              55 views
              0 likes
              Last Post dp8282
              by dp8282
               
              Started by iceman2018, Today, 05:07 PM
              0 responses
              6 views
              0 likes
              Last Post iceman2018  
              Working...
              X