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

Detect non-existance of secondary Instrument

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

    Detect non-existance of secondary Instrument

    Anyway to tell after using Add() to add a secondary instrument, whether or not it was actually Added?

    I can see in the log tab when the instrument is not available from my provider but I need a way to determine this fact programatically...

    Thx,
    Dave

    #2
    Hello BigWaveDave,
    Thanks for your note.

    Unfortunatley there are no native way to do it however you can simply check for the minimum bars for the bar series to do it
    Code:
    if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired) return;
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Originally posted by BigWaveDave View Post
      Anyway to tell after using Add() to add a secondary instrument, whether or not it was actually Added?

      I can see in the log tab when the instrument is not available from my provider but I need a way to determine this fact programatically...

      Thx,
      Dave
      Use try ... catch block, and catch the exception if any.

      ref: http://msdn.microsoft.com/en-us/libr...(v=vs.90).aspx

      Comment


        #4
        Good idea. I'm lazy though. Do you know for a fact that NT throws an exception in this case?

        Comment


          #5
          Originally posted by BigWaveDave View Post
          Good idea. I'm lazy though. Do you know for a fact that NT throws an exception in this case?
          I am reasonably certain that NT throws an exception. After all, NT does refuse to produce output. If I remember right, it even logs a message to the effect that: "index was out of bounds of the array" or some such.

          ref: https://www.google.com/search?hl=en&...rp.XjiMkiSALMQ

          Comment


            #6
            I guess if one were not to check CurrentBars before attempting to access the array, you'd certainly get an exception thrown. That test is effectively equivalent to the original suggestion and would work...

            Just wondering if "Add()" throws an exception in this case. I'll try it out.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by samish18, Today, 01:01 PM
            0 responses
            1 view
            0 likes
            Last Post samish18  
            Started by WHICKED, Today, 12:56 PM
            0 responses
            4 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Started by Spiderbird, Today, 12:15 PM
            2 responses
            10 views
            0 likes
            Last Post Spiderbird  
            Started by WHICKED, Today, 12:45 PM
            0 responses
            7 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Started by FrazMann, Today, 11:21 AM
            2 responses
            6 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Working...
            X