Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How realistic backtesting continuous contract is?

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

    How realistic backtesting continuous contract is?

    Hi, NT,
    I have a strategy backtest on NQ for 10 years of data. This is a long-term strategy and some of the trades last more than a year.

    It doesn't seems to be rolling-over contract so I assume that the roll-over fees isn't calculated in it.

    I would like my backtests to be as realistic as they can get. I'll appreciate your help.

    On another note, how can I backtest a strategy that actually rollovers or re-enter the next future upon expiry?

    #2
    Hello dastaan,

    Below is a link to a forum post on the Merge Policy.


    No, fees such as rollover fees would not be calculated in a backtest.

    "how can I backtest a strategy that actually rollovers or re-enter the next future upon expiry?"

    Use the MergeBackAdjusted merge policy with data loaded from the NinjaTrader connection.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Isn't the MergeBackAdjusted the default policy? If so, how would my backtest get out and re-enter the next contract?

      Do you mean "MergeNonBackAdjusted" because it is more realistic? In the real world won't we exit the current contract and hop on the next one by paying the premium(gap)?

      Comment


        #4
        Hello dastaan,

        MergeBackAdjusted is the default value. This is why you can backtest over a year of minute / day data and the data loads properly.

        As this is a backtest, the strategy does not have to rollover. The merge policy handles this by stitching the proper data together.

        " In the real world won't we exit the current contract and hop on the next one by paying the premium(gap)?"

        With live positions, these would need to be exited on the expiring contract month and entered into the next (or rollover the position on the strategies tab of the control center)
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you for the explanation.

          Is there any way I can implement such a method that calculates the roll-over fee or re-enters live positions upon expiry?

          I would like my backtests to have that cost included.
          Last edited by dastaan; 07-19-2024, 10:18 AM.

          Comment


            #6
            Hello dastaan,

            Unfortunately, there is not a property for this.

            You would need to manually subtract this from the net pnl.

            (Using commission templates would not be affective as that would apply to all orders)
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi, also having troubles with backtesting....how can i run a backtest of NQ futures for the year 2023?? thank you

              Comment


                #8
                Hello TimWie,

                Welcome to the NinjaTrader forums!

                Ensure you are connected to NinjaTrader Brokerage for historical data.

                In the Strategy Analyzer select the NQ 09-24 as the instrument.

                Set the Start date to Jan 1st 2023, set the end date to Dec 31st 2023.

                Click Run
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chelsea,
                  thx for your reply. Iam connected to NT continum for historical Data under "Market Data"...but it doesnt work?

                  What could be wrong??

                  Comment


                    #10
                    Hello TimWie,

                    If the strategy is in the Strategy Analyzer, is there data appearing on the Chart Display of the Strategy Analyzer?
                    Importantly, are there errors appearing on the Log tab of the Control Center?

                    Try testing the Sample MA Crossover strategy included with NinjaTrader on the same chart or Strategy Analyzer using the same instrument, bar type, interval, and date range.
                    Do you see results with the Sample MA Crossover strategy? (This would confirm for us data is available and the issue is with the logic in the custom script)

                    If the strategy is getting data and the strategy is enabled or a backtest is run with no errors in the Log tab of the Control Center, and the Sample MA Crossover is returning results, then would likely indicate the logic conditions in the custom strategy did not evaluate as true or orders are being ignored or cancelled.

                    In order to better understand how the code is working, it will be necessary to use Print to see how the conditions are evaluating and enable TraceOrders to see if orders are being submitted, ignored, rejected, or cancelled.

                    Below is a link to a support article that demonstrates using prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.


                    Enable TraceOrders, print the time of the bar and all values used in the conditions that submit entry orders. Include labels for all values and comparison operators.
                    Let me know if you need any assistance creating a print or enabling TraceOrders.

                    Save the output from the output window to a text file and provide this with your reply.
                    I'll be happy to assist with analyzing the output.​
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NullPointStrategies, Today, 05:17 AM
                    0 responses
                    41 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    124 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    64 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    41 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    46 views
                    0 likes
                    Last Post TheRealMorford  
                    Working...
                    X