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 rocketman7, Today, 02:12 AM
      1 response
      16 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by briansaul, Today, 05:31 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by PaulMohn, Today, 03:49 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by frslvr, 04-11-2024, 07:26 AM
      6 responses
      106 views
      1 like
      Last Post NinjaTrader_BrandonH  
      Started by trilliantrader, 04-18-2024, 08:16 AM
      6 responses
      26 views
      0 likes
      Last Post trilliantrader  
      Working...
      X