Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding same instrument, different expiry

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

    Adding same instrument, different expiry

    I am trying to write a simple strategy to provide volume-based rollover alerts.

    When I add a futures instrument with two different expiry months and reference the data using Closes[instrument index][period], Volumes[instrument index][period], etc... I get the same data under both instrument indices. What am I doing wrong? When I switch the 6E 06-11 to 6B 03-11 the code works fine.


    protectedoverridevoid Initialize()
    {
    // Add a 60 minute Bars object to the strategy
    Add("6E 03-11", PeriodType.Minute, timeScaleInMinutes, MarketDataType.Last); // MarketDataType.Last

    // Add a 60 minute Bars object to the strategy
    Add("6E 06-11", PeriodType.Minute, timeScaleInMinutes, MarketDataType.Last); // MarketDataType.Last
    }


    protectedoverridevoid OnBarUpdate()
    {
    //

    if (BarsInProgress == 0 || BarsInProgress > 2 )
    {
    return;
    }
    elseif (BarsInProgress == 1 || BarsInProgress == 2)
    {
    Print(Volumes[
    1][0] + "|" + Volumes[2][0] );
    }


    }

    #2
    Hello,

    When using Auto Merge in NinjaTrader 7 you cannot look at a future contract. As the current time your looking at would be merged into the 06-11 contract which means your simply seing the 03-11 data merged into the 06-11 contract for this time, which is the same data and same volume in your case.

    You would need to turn off the auto merge feature to look at a future contract that has not passed its rollover date.

    Control Center->Tools->Options->Data Tab->MergePolicy->DoNotMerge.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      Thank you for your prompt reply.

      I am trading a long-term trend following system on 100+ futures markets. It was very easy to automate the signal generation in NinjaTrader, but automating the roll trades has proved more difficult. I would like to create an automated process to roll my front month position into the next month based on a roll DateTime or when a volume comparison condition evaluates true. I need the continuous contract to generate signals but I need to manage my position in the individual contracts. In order to do this I need both individual contract data and continuous contract data.

      Is it possible to set the DoNotMerge flag so that I can get data on individual contracts and then set up a new instrument that maps to a continuous contract on another data feed (like Kinetick/DTN IQFeed or eSignal) that can be used for signal generation? Also, was there an approach to solving this common problem in futures trading that the creators of NinjaTrader had in mind when they implemented the new continuous contract features?

      Comment


        #4
        Hello,

        What is your data feed provider?

        I look forward to assisting you further.
        BrettNinjaTrader Product Management

        Comment


          #5
          I use both kinetick and eSignal.

          Comment


            #6
            Is it possible to create a new instrument in the instrument manager, say 6E_C, that has the same setup as 6E except with a different merge policy? When I try this I can't seem to get the new instrument to link to my real-time feeds even after I have provided the correct symbol mappings

            Comment


              #7
              Hello,

              Dont think this is the way to go then you will end up with some executions on some instruments I believe you would have issues here.

              The only option left then in this case is to run with do not merge. Then manually add in the historical data by importing it from the previous contracts into the 03-11 contract.

              Otherwise if this is not acceptable then this would be unfortunately unsupported.

              Let me know if I can be of further assistance.
              BrettNinjaTrader Product Management

              Comment


                #8
                Once I shut NT7 down and restarted it I was able to get data on my new instrument (i.e., 6E_C). I think I will be able to trade the actual contracts by setting the DoNotMerge flag and just run my signal off the contract set to back adjust. If I get something that runs I will post it to the forum for others who are having similar problems.

                Comment


                  #9
                  Is it possible to add an instrument outside of Initialize() ? Perhaps I can add new instruments and remove old instruments from the same strategy instance.

                  Comment


                    #10
                    Hello,

                    Ok thanks please let us know and for others that may experience the same.

                    Also, this would be unsupported and untested if this will work or not work.

                    Let me know if I can be of further assistance.
                    BrettNinjaTrader Product Management

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    579 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    334 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    101 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    554 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    551 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X