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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      160 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      307 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      244 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      348 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      178 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X