Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Set secondary instrument from user input

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

    Set secondary instrument from user input

    I refer to the documentation about AddDataSeries() quoted here:

    "This method should ONLY be called from the OnStateChange() method during State.Configure
    Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input)."

    So, while I can read and understand what has been said there, I am still looking for a way to enable the user of my indicator to specify the instrument symbol and the time frame, like "MSFT", Minute and 10.

    I created three properties, SecondaryInstrument, SecondaryPeriodType, and SecondaryPeriod so my user can set the values. I then put this line of code in State.Configure of the OnStateChange() method:

    Code:
    AddDataSeries(SecondaryInstrument, SecondaryPeriodType, SecondaryPeriod, Data.MarketDataType.Last);
    It worked, which didn't surprise me, but the documentation is saying that it is unsupported, if I am reading it correctly.

    So I have two questions:

    1) Is this approach really inappropriate; will it cause problems?

    2) If this approach is not supported, how can I enable my indicator user to specify the instrument and time frame for my indicator?

    Thanks!
    sh_daggett
    NinjaTrader Ecosystem Vendor - NinjaLaunchpad

    #2
    Hello sh_daggett,

    Thank you for your post.

    You have performed this correctly. The documentation is referring to setting the AddDataSeries() based on the primary series values. For example, the following would be incorrect:
    Code:
    AddDataSeries(Secondaryinstrument, Bars.BarsPeriod.BarsPeriodType, Bars.BarsPeriod.Value);
    The above would be incorrect as the data has not loaded (State.DataLoaded) for the primary series yet.

    Please let me know if you have any questions.

    Comment


      #3
      Hi Patrick,

      Thanks for your speedy reply. You folks are awesome!

      I think I understand your reply. Here's how I understand it: The code sample you provided won't work because it is referring to the primary series from within State.Configure, which it can't do because that series has not loaded yet. However, I can legally use user inputs (obtained from the Indicators Properties panel) in the AddDataSeries method from within State.Configure without concern.

      Let me know if I get it wrong, and thanks again for your quick reply!
      sh_daggett
      NinjaTrader Ecosystem Vendor - NinjaLaunchpad

      Comment


        #4
        That is correct!

        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
        331 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
        549 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