Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Index of data series, or instance of indicator

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

    Index of data series, or instance of indicator

    Hi,

    I'm adding multiple instances of the same indicator to a chart and I want to identify each one. Each indicator points to a different data series on the same chart.

    So, say 5 data series, 5 copies of the indicator.

    For some simple offsets for text, I want, but preferably without manually setting anything to have an index for the indicators, 0, 1, 2, 3, etc.

    The easiest way I can think of to do this would be to get either the index of the instance of the indicator, or the index of the data series in use by the indicator. I cannot however see how to do this.

    Is there a way?

    Thanks.

    #2
    Hello pjsmith,

    Thank you for your post.

    You would need to use the ChartPanel.ChartObjects. Unfortunately, there is no instance to pull from so you essentially need to create your own way to track the instance. Below is an example where we increase an int's count by how many objects exist on the chart. We can then use this as the "instance".
    Code:
    			if (ChartControl != null)
    			{				
    				IList<Gui.NinjaScript.IChartObject> myObjects = ChartPanel.ChartObjects;
    				
    				int objectCount = 0;
    				
    				foreach (Gui.NinjaScript.IChartObject thisObject in myObjects)
    				{					
    					if (thisObject is ChartBars)
    					{
    						objectCount++;
    						
    						ChartBars test = thisObject as ChartBars;
    
    						if (test.ToChartString() == BarsArray[0].ToChartString())
    						{
    							// use objectCount as you means to offset
    						}
    					}
    				}
    			}
    For information on ChartObjects please visit the following link: https://ninjatrader.com/support/help...artobjects.htm

    Please let me know if you have any questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    562 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    325 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
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X