Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

can I use an Array to define series names?

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

    can I use an Array to define series names?

    I have an excel file that has multiple "strategies" in it.
    I read in values for different indicators from the excel file depending on the strategy chosen.
    My input goes into an array called "descArray[]". The text in the array is the name of an indicator as shown below.
    Each strategy uses a different combination of the 14 indicators listed below

    index Indicator name
    index: 0: OBV
    index: 1: CMF
    index: 2: OVB2Signal
    index: 3: MOM
    index: 4: Dad
    index: 5: K
    index: 6: D
    index: 7: SF
    index: 8: DCycleHL
    index: 9: KCycleHL
    index: 10: InsideLRC
    index: 11: HA
    index: 12: HAOpposing
    index: 13: TREND

    Since I don't use all 14 indicators for each strategy, I want to create my series and plots based only on the values read in from the excel file.

    Is there a way to use the array value in place of hard coding the values in the series declaration?
    For example in the 1st line below instead of hard coding OBV, can I use descArray[0] which contains the string "OBV"?

    I know I can't directly do that, but is there a workaround for what I'm trying to accomplish? That turns my series declaration below into a for loop that only creates the series for indicators that are read from the excel file. And prevents me from having series (and plots) for indicators that aren't used with the current strategy

    [Browsable(false)] [XmlIgnore] public Series<double> OBV { get { return Values[0]; } }
    [Browsable(false)] [XmlIgnore] public Series<double> CMF { get { return Values[1]; } }
    [Browsable(false)] [XmlIgnore] public Series<double> OBVSignal { get { return Values[2]; } }
    [Browsable(false)] [XmlIgnore] public Series<double> MOM { get { return Values[3]; } }
    [Browsable(false)] [XmlIgnore] public Series<double> Dad { get { return Values[4]; } }
    [Browsable(false)] [XmlIgnore] public Series<double> K { get { return Values[5]; } }
    [Browsable(false)] [XmlIgnore] public Series<double> D { get { return Values[6]; } }
    [Browsable(false)] [XmlIgnore] public Series<double> SF { get { return Values[7]; } }
    [Browsable(false)] [XmlIgnore] public Series<double> DCycleH { get { return Values[8]; } }
    [Browsable(false)] [XmlIgnore] public Series<double> KCycleH { get { return Values[9]; } }
    [Browsable(false)] [XmlIgnore] public Series<double> InsideLRC { get { return Values[10]; }}
    [Browsable(false)] [XmlIgnore] public Series<double> HA { get { return Values[11]; }}
    [Browsable(false)] [XmlIgnore] public Series<double> HAOpposing { get { return Values[12]; }}
    [Browsable(false)] [XmlIgnore] public Series<double> Trend { get { return Values[13]; }}

    any way to do this?

    #2
    Aslo, I can't read in the data until State.Configure, so would have to declare the series in Configure or later

    Comment


      #3
      Hello cre8able,

      These public series are returning Plot series that are added with AddPlot().

      These are already in a collection called Values.
      https://ninjatrader.com/support/help...nt8/values.htm

      You don't have to make public series that return Plot series if you don't want to.

      But likely you could create an array of series.

      private Series<double>[] arrayOfSeries;

      arrayOfSeries = new Series<double>[]
      {
      new Series<double>(this),
      new Series<double>(this)
      };

      Custom Series objects are created in State.DataLoaded or later.
      https://ninjatrader.com/support/help...t8/seriest.htm
      Last edited by NinjaTrader_ChelseaB; 06-09-2021, 07:25 AM.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        that was easy

        thanks Chelsea

        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