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

Get instruments loaded on chart

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

    Get instruments loaded on chart

    Hello,

    I thought this would be simple, but in trying, cannot see a way to do it.

    if I add an indicator to a chart, how can I find the instruments loaded on that chart, be it 1, 2, or many? I thought it would just be a case for foreach (Instrument I in Instruments), but that only seems to give me the main instrument and anything added within the indicator itself, by adddataseries.

    Any way to do it?

    Thanks.
    Last edited by pjsmith; 08-15-2019, 10:33 AM.

    #2
    Hello pjsmith,

    Thanks for your inquiry.

    This can be found in ChartControl.BarsArray.

    Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
        // Instantiate a new <ChartControl>.BarsArray collection
        System.Collections.ObjectModel.ObservableCollection<ChartBars> myChartBars = chartControl.BarsArray;
    
        // Print the number of bars in each Bars object within the <ChartControl>.BarsArray collection
        foreach(ChartBars bars in myChartBars)
        {
            Print(bars.Bars.Instrument.FullName);
        }
    }


    Please let us know if there is anything else we can do to help.
    JimNinjaTrader Customer Service

    Comment


      #3
      Perfect. Thank you Jim

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      27 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 04-23-2024, 09:53 PM
      2 responses
      49 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      193 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,235 views
      0 likes
      Last Post xiinteractive  
      Working...
      X