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

Calcualte front month?

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

    Calcualte front month?

    Scenario: I add an additional instrument to a chart.

    Is there a way to calculate the front month other than calculating it using the current month and knowing the rollover rules for the instrument in the indicator?
    I didn't know if there was something existing in Ninja Trader that would tell me the current front month for an instrument.

    I am surely not the first person to need this but if so I can code it easy enough.

    Cheers
    Last edited by ct; 05-06-2021, 01:24 AM.

    #2
    Hello ct,

    (edit, I overlooked this is in the NinjaTrader 7 section of the forums)
    https://ninjatraderecosystem.com/use...erindications/

    It is possible to calculate the next rollover by looking at the Instrument.MasterInstrument.RollOverCollection.

    The RolloverIndications indicator calculates the next front month and you can use this as an example.
    https://ninjatraderecosystem.com/user-app-share-download/rolloverindications/


    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
    Last edited by NinjaTrader_Jim; 05-07-2021, 08:25 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ChelseaB

      That looks like the ticket.

      I do have MergePolicy.DoNotMerge as I want to see only volume for the contract period i am working with. I will need to evaluate the impact of a change to this setting.

      Many thanks.

      Cheers

      Comment


        #4
        ChelseaB

        How do I get the RollOverCollection for an instrument other than the chart instrument?

        Scenario: I am on a YM chart and want to add the "RTY". How do I request the RollOverCollection for the RTY?

        I tried replacing "MasterInstrument.RollOverCollection" with "RTY".RollOverCollection" but it wasn't happy.

        Cheers


        Comment


          #5
          Hello ct,

          You could try the following:

          Code:
          foreach (Instrument inst in Instruments)
          {
              if (inst.MasterInstrument.Name == "ES")
                  foreach (RollOver rollover in inst.MasterInstrument.RollOverCollection)
                      Print(rollover.ToString());
          }
          This works in Initialize, but if you are trying to use it to dynamically add data, this may not always work as it is not 100% supported. You could try writing some logic that uses DateTime.Now in the logic to identify the appropriate rollover to use, and this may be better than trying to use the primary data series Instrument to look up what the current contract period would be.

          Accessing the RoolOverCollection in NtinjaTrader 7 is not a documented/supported item, but the NinjaTrader 8 help guide can be helpful to get some hints on using.



          We look forward to assisting.
          JimNinjaTrader Customer Service

          Comment


            #6
            Jim

            I can make this work.

            Many thanks.

            Cheers
            Cliff

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,606 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            8 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            13 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X