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

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.
    JimNinjaTrader Customer Service

    Comment


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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by andrewtrades, Today, 04:57 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      3 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      6 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X