Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get front contracts dates?

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

    How to get front contracts dates?

    I have list of futures like this:
    NQ,CL,GC

    I need to convert it into front contracts:
    NQ 03-22,CL 03-22,GC 04-22

    Would be great if it can be done via NinjaScript.
    Thanks.

    #2
    Hello Leeroy_Jenkins,

    Thanks for your post.

    If you are trying to add additional data series to a custom NinjaScript, you could do so by calling AddDataSeries() and specifying the instrument and contract date of the instrument. For example, see below.

    //Add a 5-minute series for NQ 03-22 instrument
    AddDataSeries("NQ 03-22", BarsPeriodType.Minute, 5);

    See this help guide documentation for more information: https://ninjatrader.com/support/help...dataseries.htm

    Note that there are no documented means for converting, for example, NQ to NQ 03-22

    Let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      I'm trying to make list of symbols that I'm gonna trade. Because this list changes a few times in a week, I though it would be great if NT just parses from file my symbols.

      Note that there are no documented means for converting, for example, NQ to NQ 03-22
      That's the problem. Even though it's possible to access to contract rollovers via RolloverCollection, there is no way to get current front contracts.

      Or If I try to import symbols manually it doesn't convert NQ to NQ 03-22.

      And there is no way to create instrument list via NinjaScript.

      Dead end.

      Comment


        #4
        Hello Leeroy_Jenkins,

        Thanks for your note.

        It might be possible through unsupported code to add an entire instrument list through the code. However, this would break the warning we provide in the Help Guide linked and listed below.

        As stated in the AddDataSeries() help guide page: Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error.

        AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm

        This thread will be open for other forum community members to share their insight.

        Let us know if we may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          You can use NinjaScript to determine the Instrument associated with the "Next Expiry" date of the MasterInstrument as follows:
          Code:
          string MasterName = "ES";    // For example
          Instrument CurrentContract = Instrument.GetInstrument(MasterName + Instrument.GetInstrument(MasterName+" ##-##").MasterInstrument.GetNextExpiry(DateTime.Now).ToString(" MM-yy"));
          Running this today produces ES 03-22.

          Hope that helps.

          Thanks.
          Multi-Dimensional Managed Trading
          jeronymite
          NinjaTrader Ecosystem Vendor - Mizpah Software

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          571 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          330 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
          548 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          549 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X