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

Current Contract

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

    Current Contract

    I notice that when I add an instrument to my Instrument List via the Instrument Manager, it always adds the current contract. Is there a way I can test for the current contract of a futures instrument from an indicator?

    #2
    Hi Brad, this is unfortunately not possible as the rollover dates could not be accessed programmatically.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Would you have any suggestiions then as to how I test the validity of a contract then? I have parameters which allow a user to specify the instrument and contract to be added to an indicator. If they type in an invalid contract the indi dies with a divide by zero error. I'm trying find a way to either test the parameter for a valid contract and/or capture the error so I can display an appropriate message to the user.

      Comment


        #4
        Hello,

        No way to test the validity of the contract that I can think off.

        About the only thing you can do is trap the error with c# using try() {} catch() {} blocks.

        More information on using try catch blocks if your not familiur with them can be gound online.

        Let me know if I can be of further assistance.

        Comment


          #5
          Thanks Brett...but I have tried using try/catch and they don't seem to work during initialization where the ADD takes place.

          Comment


            #6
            Can you give me an example of an incorrect entry for the parameter of Add() for the instrument that would cause the divide/0 error.

            Also, do you have anything else in Initialize() other then the adds, if so please post them.

            I look forward to assisting you further.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by DJ888, Today, 10:57 PM
            0 responses
            2 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by MacDad, 02-25-2024, 11:48 PM
            7 responses
            158 views
            0 likes
            Last Post loganjarosz123  
            Started by Belfortbucks, Today, 09:29 PM
            0 responses
            7 views
            0 likes
            Last Post Belfortbucks  
            Started by zstheorist, Today, 07:52 PM
            0 responses
            7 views
            0 likes
            Last Post zstheorist  
            Started by pmachiraju, 11-01-2023, 04:46 AM
            8 responses
            151 views
            0 likes
            Last Post rehmans
            by rehmans
             
            Working...
            X