Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Calendar Spread Backtesting

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

    Calendar Spread Backtesting

    Hi there,

    I am trying to build a calendar spread backtester for grains. When I print the close of each bar, I get the same price for each future. For example, the current front contract for CBOT Wheat is "ZW 09-20" and the next future is "ZW 12-20". When I print the close of historical bars in the Output window during a backtester, the output of the two symbols is the same. (I set up Sep as the main Strategy Analyzer instrument and Dec as the added instrument in the file.)

    Can someone recommend a way to build a backtester that allows me to look at the both the front wheat contract and the one-back wheat contract throughout a historical window for backtesting purposes?

    Thank you,
    Tim



    #2
    Hello ozziyhtomit,

    Thanks for your post.

    This sounds like your data series are getting merged. Do you see the same behavior when you set Merge Policy to Do Not Merge?

    (Control Center > Tools > Options > Market Data > Merge Policy)



    I look forward to your reply.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hey Jim

      Yes they now match the actual current market prices. Thanks!

      Just to confirm: If I use 'Do Not Merge', the backtester will allow me to differentiate bw front and one-back futures in a strategy file. However, will NT roll both contracts in the backtester? In the Jan of 2020 part of the backtesting, will the front be the Mar 2020 and the one-back be the May 2020?

      My goal is to backtest an idea over the past few years studying the relationship bw the front and one-back future for each time interval in the backtester. This is not the same as wanting to backtest what the "ZW 09-20" and "ZW 12-20" contracts did over the past 24 months.

      Thanks!


      Comment


        #4
        Hello ozziyhtomit,

        Do Not Merge will prevent previous contract periods from being merged with the next contract period. In January 2020, each data series will be of the trades for that individual instrument/expiry at that time.

        To accomplish your goal you may want to consider the following:

        1. Use Do Not Merge so each data series only contains the trades from their contract period
        2. Add additional data series to your script for each contract period you want to study over that interval
        3. Throughout your strategy logic, use time checks to switch between which front contract period and previous contract period you want to analyze.

        More information on adding multiple data series and working with Multi Time Frame strategies can be found below.



        We look forward to assisting.
        JimNinjaTrader Customer Service

        Comment


          #5
          Thanks Jim

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Perr0Grande, Today, 08:16 PM
          0 responses
          2 views
          0 likes
          Last Post Perr0Grande  
          Started by elderan, Today, 08:03 PM
          0 responses
          5 views
          0 likes
          Last Post elderan
          by elderan
           
          Started by algospoke, Today, 06:40 PM
          0 responses
          10 views
          0 likes
          Last Post algospoke  
          Started by maybeimnotrader, Today, 05:46 PM
          0 responses
          12 views
          0 likes
          Last Post maybeimnotrader  
          Started by quantismo, Today, 05:13 PM
          0 responses
          7 views
          0 likes
          Last Post quantismo  
          Working...
          X