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 chbruno, Today, 04:10 PM
              0 responses
              3 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              436 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              6 views
              0 likes
              Last Post FAQtrader  
              Started by rocketman7, Today, 09:41 AM
              5 responses
              19 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by frslvr, 04-11-2024, 07:26 AM
              9 responses
              127 views
              1 like
              Last Post caryc123  
              Working...
              X