Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optional instrument

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

    Optional instrument

    Scenario: I have an strategy that uses an instrument that comes from a secondary data feed. I have a friend that wants to use my strategy. They don't have the secondary data feed.

    Question: If they don't have the feed or instrument active what will the NT strategy do? I didn't know if I needed to modify it to make the check optional or if it would just return zeros on the values.

    Cliff

    #2
    Good question. Although I believe I know what will happen, I will need to double check with Dierk. He will likely reply later on late this evening.
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks Ray

      ok, I didn't want to remove it my system and erase my history if I didn't have to.

      Cliff

      Comment


        #4
        He needs to have a feed for the secondary instrument as well. No data -> no OnBarUpdate will be triggered.

        Comment


          #5
          Detecting if datafeed/instrument is available?

          In addition to this topic, how one can detect programmatically if a call to BaseStrategy.Add() was successful, and corresponding instrument will be available in OnBarUpdate at expected index through BarsArray/Opens/Closes etc properties?

          Scenario:
          Initialize()
          {
          Add("Secondary feed instrument", Ticks, 50);
          Add("Primary feed instrument");
          }
          OnBarUpdate()
          {
          BarsArray[1] // <-- what instrument it will refer to if there was no secondary feed?
          }

          Thanks!

          p.s. Testing whether BarsArray.Length increased after Add() causes run-time exception (cannot access BarsArray property in Initialize() method...).
          Last edited by imisuno; 05-15-2007, 08:27 AM.

          Comment


            #6
            Hi,

            1) If there was no instrument in BarsArray[1] then the strategy would throw an exception (seen in the Log tab) and terminate

            2) Correct, you can not access BarsArray from the Initialize() method
            RayNinjaTrader Customer Service

            Comment


              #7
              Ray, thank you very much.
              Sorry, I have not described in details what I am trying to achieve. I need to know at runtime whether instrument was added successfully or not, i.e., which instrument BarsArray[1] would refer to, in the example below, "Secondary feed" or "Primary", so that my strategy will know which instruments it is using.

              Sure, I can add all primary instruments first and then detect that there are no secondary ones, and to disable all checks involved. Ok, I think this is acceptable.

              Thank you again.

              Comment


                #8
                You have to perform the check in OnBarUpdate().

                Code:
                if (BarsArray[1] != null)
                    Print(Instruments[1].FullName);
                RayNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                633 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                364 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                105 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                567 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                568 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X