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 hazylizard, Today, 08:38 AM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by geddyisodin, Today, 05:20 AM
      2 responses
      18 views
      0 likes
      Last Post geddyisodin  
      Started by Max238, Today, 01:28 AM
      5 responses
      47 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by giulyko00, Yesterday, 12:03 PM
      3 responses
      13 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by habeebft, Today, 07:27 AM
      1 response
      16 views
      0 likes
      Last Post NinjaTrader_ChristopherS  
      Working...
      X