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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      156 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      90 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      140 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      130 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      107 views
      0 likes
      Last Post CarlTrading  
      Working...
      X