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 aa731, Today, 02:54 AM
      0 responses
      4 views
      0 likes
      Last Post aa731
      by aa731
       
      Started by thanajo, 05-04-2021, 02:11 AM
      3 responses
      469 views
      0 likes
      Last Post tradingnasdaqprueba  
      Started by Christopher_R, Today, 12:29 AM
      0 responses
      10 views
      0 likes
      Last Post Christopher_R  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      166 responses
      2,237 views
      0 likes
      Last Post sidlercom80  
      Started by thread, Yesterday, 11:58 PM
      0 responses
      4 views
      0 likes
      Last Post thread
      by thread
       
      Working...
      X