Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Add SecondaryInstrument as a data series

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

    Add SecondaryInstrument as a data series

    I have a chart with 2 data series.

    I would like to add the the second charted data series as a Bars Object within a script, e.g something like this:

    protected override void Initialize()
    {

    Add(Instrument.SecondInstrument.Name);


    Is there any way to find out the name for the second instrument on the chart, so that I can add it as a Bars Object?

    #2
    Hello AntiMatter,

    Thank you for your post.

    There is no method to pull a secondary instrument applied to the chart. We only have our input series being the main series and then any series we add through code.

    Comment


      #3
      Ahaa......


      Code:
              [Description("Second instrument.")]
              [GridCategory("Parameters")]
              [Gui.Design.DisplayName ("\t\t\t\t\t\t\t\t\t\t\t\tSecond Instrument")]
              public string Symbol2
              {
                  get 
                  {   // symbol2 defaults to secondary chart data series
                      if ((symbol2 == "") && (ChartControl != null) && (Instruments != null)) 
                          for(int i=0; i<ChartControl.BarsArray.Length; i++)
                              if (ChartControl.BarsArray[i].Instrument.FullName != Instruments[0].FullName)
                              {
                                  symbol2 = ChartControl.BarsArray[i].Instrument.FullName;
                                  break;
                              }
                      return symbol2; 
                  }
                  set { symbol2 = value.ToUpper(); }
              }

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Segwin, 05-07-2018, 02:15 PM
      10 responses
      1,767 views
      0 likes
      Last Post Leafcutter  
      Started by Rapine Heihei, 04-23-2024, 07:51 PM
      2 responses
      30 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by Shansen, 08-30-2019, 10:18 PM
      24 responses
      943 views
      0 likes
      Last Post spwizard  
      Started by Max238, Today, 01:28 AM
      0 responses
      9 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by rocketman7, Today, 01:00 AM
      0 responses
      7 views
      0 likes
      Last Post rocketman7  
      Working...
      X