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 cmoran13, 04-16-2026, 01:02 PM
    0 responses
    46 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    28 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    163 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    98 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    158 views
    2 likes
    Last Post CaptainJack  
    Working...
    X