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

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 ZenCortexCLICK, Today, 04:58 AM
    0 responses
    2 views
    0 likes
    Last Post ZenCortexCLICK  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    172 responses
    2,280 views
    0 likes
    Last Post sidlercom80  
    Started by Irukandji, Yesterday, 02:53 AM
    2 responses
    17 views
    0 likes
    Last Post Irukandji  
    Started by adeelshahzad, Today, 03:54 AM
    0 responses
    4 views
    0 likes
    Last Post adeelshahzad  
    Started by Barry Milan, Yesterday, 10:35 PM
    3 responses
    13 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X