.I created an indicator with a List Array and I want to access the array. My list array is on my chart indicator but I want to create another indicator in a seperate panel and use the information in the List. Is this possible?
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!
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
NinjaTrader
indicator reading another indicator
Collapse
X
-
indicator reading another indicator
Is there a way that one indicator can read another indicator?
.I created an indicator with a List Array and I want to access the array. My list array is on my chart indicator but I want to create another indicator in a seperate panel and use the information in the List. Is this possible?Tags: None
-
Hello,
Thanks for your post.
It is possible to call indicator A from indicator B, and you can choose whatever panel you like.
In order to do this you will need to expose your list by declaring it as a public class.
Most commonly you see indicators calling on other indicators to get a Plots value. The standard format for all indicators that expose plots that can be accessed is:
Indicator(overloads).plotname[BarsAgo]
If you would like to have your indicator access non-plotted values than you will want to use an available class that implements the Series interface. Series<T>
The following post goes into further detail on creating and accessing exposed objects.
Exposing things other than plots
If you have any further questions please let me know.Josh G.NinjaTrader Customer Service
-
I just need to verify something I called my Indicator, do I have to put in all my fields or can I just access the drawlist
i wrote this
if(myChartIndicator.drawList[x].PivotType == 1)
and I got an error.
do I have to do this
if(myChartIndicator(parameter,parameter,paramete, etc).drawList[x].PivotType ==1)
because all I want is the charts drawList array.
Comment
-
Hello,
"do I have to do this
if(myChartIndicator(parameter,parameter,paramete, etc).drawList[x].PivotType ==1)"
You are correct with this one, will need to include the parameters just like any indicator call.
If you have any further questions please let me know.Josh G.NinjaTrader Customer Service
Comment
-
I would like to ask a related question about Performance and Memory when using this method of accessing exposed values in another indicator as described above on NT8.
Let's assume our Main indicator (Indicator1) calls another (IndicatorX) and accesses some exposed values in IndicatorX.
1. Does IndicatorX get loaded into memory, accessed, and thrown away each time a request for an exposed value is made?
If it does then this would be quite memory and CPU intensive I would think. For example, what if Indicator1 has to access 10-20 values from IndicatorX on each chart bar that prints?
2. Is it possible in IndicatorX to Expose a single Series that contains an instatiated class full of values?
This would enable Indicator1 to make just one request to IndicatorX for data, retrieve the instatiated class and access all its field components from there.
...The perceived scenario where this might be useful would be where..
IndicatorX is responsible for all the data collection and maths using OnBarUpdate.
Indicators 1,2,3 etc. can access any of the values calculated by IndicatorX without the need to duplicate code and re-run the OnBarUpdate logic in IndicatorX.
I hope this makes sense and that you can tell me if this is the most efficient approach and whether there is an example of code that shows how point 2. can be achieved?
Thanks
Comment
-
Hello MBScalper,
1. This depends on the situation, if you mean calling the same indicator and same syntax: SMA(12)[0], no this is cached and will be reused. If you are instead calling new indicators each time :SMA(12) SMA(13) etc, a new indicator will be calculated and cached. Indicators are not disposed of until they are terminated. Exposed properties can also have the option of using the Update() method, if a property uses Update that will cause the script to have additional overhead when called.
2. I would not suggest trying to over complicate the series being exposed, generally exposing a Series<double> is the best way/most efficient. If you expose a class and instantiate an object for each slot that would take a more resources than a simple type like a double.
Your description in general is how all indicators work by default, if Indicator X does a calculation and plots it then Indicators 123 could access X to get the value it calculated. X would be calculated 1 to 3 times depending on what indicator 1,2,3 does with X. If 1,2,3 are all the same instrument and all have called X using the same parameters, it would return the cached instance. If there are differences in how X is being called, it would recalculate for that use case. You can see the same situation using a stock indicator like the SMA example from above.
Please let me know if I may be of further assistance.
JesseNinjaTrader Customer Service
Comment
-
Jesse,
Thank you for your answer. What you said makes perfect sense.
I have used update() in the properties of one of my Indicators (IndicatorX). I will look at whether it is necessary to do so in my case or not given your comment.
Example:
[Browsable(false)]
[XmlIgnore]
public Series<int> DS_Bar_Direction { get { Update();return ds_Bar_Direction; }}
I expose a whole lot of properties, most of which start off in an instatiated class and then have their values put into a series variable somewhere in the OnBarUpdate method for the purpose of exposing each one to a calling indicator. The Calling Indicator (Indicator1 - does all the clever SharpDX display stuff) has to call IndicatorX 10-20 times to get all the exposed values.
Do you know of any code example where an instantiated class is exposed?
- Since I would like to see if performance improves when IndicatorX is called and returns one instantiated class.
- This would also remove a lot of lines of code from my calling indicator.
Many thanks,Last edited by MBScalper; 11-25-2019, 12:57 PM.
Comment
-
Hello MBScalper,
I have used update() in the properties of one of my Indicators (IndicatorX). I will look at whether it is necessary to do so in my case or not given your comment.
Do you know of any code example where an instantiate class is exposed?
Series is exposed as a generic <T>, the standard use for a series would be a double however you can expose any Type.
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
Comment
-
Hi,
I have a question relating to exposed properties (similar to your example below).
double myvar = Indicator(overloads).ExposedProperty[BarsAgo];
I have an indicator which has about 30+ exposed properties. My indicator has a large number of input parameters and I am finding it cumbersome to type all those parameters/overloads each time I want to retrieve a different exposed property. Is there a way to parse a variable instead of the name of the exposed property? This way I could create a small method and parse the Property name in saving a lot of lines of code.
e.g.
double myvar = Indicator(overloads).%Variable%[BarsAgo];
Thank you.
Originally posted by NinjaTrader_JoshG View PostHello,
Thanks for your post.
It is possible to call indicator A from indicator B, and you can choose whatever panel you like.
In order to do this you will need to expose your list by declaring it as a public class.
Most commonly you see indicators calling on other indicators to get a Plots value. The standard format for all indicators that expose plots that can be accessed is:
Indicator(overloads).plotname[BarsAgo]
If you would like to have your indicator access non-plotted values than you will want to use an available class that implements the Series interface. Series<T>
The following post goes into further detail on creating and accessing exposed objects.
Exposing things other than plots
http://ninjatrader.com/support/forum...ead.php?t=4991
If you have any further questions please let me know.Last edited by MBScalper; 12-09-2020, 10:58 PM.
Comment
-
Hello MBScalper,
No but you could just use a variable for the indicator its self. The most simple way to do that is to generate the code with the strategy builder. If you use the indicator in any type of condition and click View Code you will get the correct variable for the indicator.
You could do:
IndicatorName myIndicator = IndicatorName(overloads);
Then later you would use myIndicator.plotName[BarsAgo]
JesseNinjaTrader Customer Service
Comment
-
Fantastic!!!
So simple and saved me hundreds of lines of code too.
Thanks
Originally posted by NinjaTrader_Jesse View PostHello MBScalper,
No but you could just use a variable for the indicator its self. The most simple way to do that is to generate the code with the strategy builder. If you use the indicator in any type of condition and click View Code you will get the correct variable for the indicator.
You could do:
IndicatorName myIndicator = IndicatorName(overloads);
Then later you would use myIndicator.plotName[BarsAgo]
Comment
-
Question: when I have one indicator already loaded on the chart, and a second shall retrieve data from the first indicator, would NT cache the first indicator a second time or is there a way to call exactly this instance.
As parameters may change, I wonder if there is a way to get the parameters of the currently loaded indicator. Maybe with something similar like chartControl.Indicators
And is hosting the indicator as an object the most resource efficient way?
The thing is, since OnRender doesn't allow drawing on different price panels, you need an indicator for each panel. But in the end it shall just extend the first indicator and not cause a second instance of it. It shall save resources by not using the Draw Method which has the DrawOnPricePanel feature.
Greetings
Comment
-
Hello seykool,
When using indicators that have the same data and parameters the cache would be used to use the existing instance.
From what you described it sounds like you would need just apply the indicator twice to the chart, once on the first price panel and then again on the second price panel.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by johnMoss, 03-04-2024, 01:53 PM
|
3 responses
46 views
0 likes
|
Last Post
by AndyM
Today, 06:13 PM
|
||
Started by algospoke, Today, 06:01 PM
|
0 responses
7 views
0 likes
|
Last Post
by algospoke
Today, 06:01 PM
|
||
Started by cre8able, Today, 05:53 PM
|
0 responses
8 views
0 likes
|
Last Post
by cre8able
Today, 05:53 PM
|
||
Started by Wessel, 03-23-2024, 02:37 PM
|
3 responses
24 views
0 likes
|
Last Post Today, 04:58 PM | ||
Started by martini, Yesterday, 04:45 PM
|
4 responses
32 views
0 likes
|
Last Post
by martini
Today, 04:48 PM
|
Comment