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 rhyminkevin, Today, 04:58 PM
    4 responses
    52 views
    0 likes
    Last Post dp8282
    by dp8282
     
    Started by iceman2018, Today, 05:07 PM
    0 responses
    5 views
    0 likes
    Last Post iceman2018  
    Started by lightsun47, Today, 03:51 PM
    0 responses
    7 views
    0 likes
    Last Post lightsun47  
    Started by 00nevest, Today, 02:27 PM
    1 response
    14 views
    0 likes
    Last Post 00nevest  
    Started by futtrader, 04-21-2024, 01:50 AM
    4 responses
    50 views
    0 likes
    Last Post futtrader  
    Working...
    X