Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can a strategy get the symbol of its primary data series

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

    Can a strategy get the symbol of its primary data series

    The primary data series of a strategy is set outside of the strategy. Is there a way for the strategy code to get the symbol of its primary data series??

    Thanks,
    ++PLS

    #2
    pls2000, you can work with the Instrument class for this task - http://www.ninjatrader.com/support/h...instrument.htm

    Comment


      #3
      Yes, but how do I get the relevant Instrument object?

      For the primary data series, I can start with a Bars object via BarsArray or with an IDataSeries object via Close[0]. Neither one is document to have a reference to an Instrument.

      ++PLS

      Comment


        #4
        You can check the instrument directly in the given BarsInProgress, it would be reporting in the called context.

        Comment


          #5
          BarsInProgress is an int. It doesn't refer to anything. As I said, I have BarsArray and CLose as starting points. Neither of thiese documents a reference to an Instrument object.

          Can you post a code example of getting the Instrument?

          Thanks,
          ++PLS

          Comment


            #6
            Correct, BarsInProgress is an int that would show which series OnBarUpdate() is currently called, your Instrument will report it's properties dynamically based on the context.

            if (BarsInProgress == 0)
            Print(Instrument.FullName); // Primary instrument full name

            if (BarsInProgress == 1)
            Print(Instrument.FullName); // Secondary instrument full name

            Comment


              #7
              Got it. Thanks.

              Sometimes your practice of using exactly the same name for a class and a variable gets confusing.

              ++PLS

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              571 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              330 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              548 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              549 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X