Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            656 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            371 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            574 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            579 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X