Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting Instrument with current contract

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

    Getting Instrument with current contract

    If I open a chart, and click the magnifying glass on the toolbar, and select a futures instrument from the instrument selector, the chart opens with the correct contract - having the next expiration.

    How can I do this in code? e.g. search for an instrument by name "ES" and have it return me the correct contract "ES 06-18" same as it does with the instrument search on the chart?

    I've tried out the various static methods on the Instrument class but I am not able to get the correct contract.

    thank you

    Suzie

    #2
    Hello Suzie,

    Thanks for your inquiry.

    Another user on the forums, xcondor, has shared some sample code that you may wish to reference to accomplish the job. Please see his post here: https://ninjatrader.com/support/foru...23&postcount=5

    Public documentation on the Instrument methods and properties used in this code can be referenced below.

    GetInstrument() - https://ninjatrader.com/support/help...instrument.htm

    MasterInstrument.Name - https://ninjatrader.com/support/help...ument_name.htm

    MasterInstrument.GetNextExpiry - https://ninjatrader.com/support/help...nextexpiry.htm

    Please let me know if you have any questions.

    Comment


      #3
      Thanks for the info Jim I shall give it a shot.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      569 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
      548 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X