Accessing another indicator from within an indicator?
I have an indicator that I use that plots a 20 period moving average from a 5min chart on a 1 min chart. I like it better than using a "proxy", but I would like to be able to access its value from with in another indicator that I wrote. Not sure what I need to do to be able to access an indicator from with in an indicator? Anyone have some sample code they could share? Not the regular indicators either like a built in Ninja EMA, I got that. Thanks for any advice.
If you want to access a first indicator from within a second indicator, this is possible, if the following conditions are met.:
(1) The first indicator must have the values that you want to access exposed in the properties. You cannot access values that are not exposed
(2) Some further restrictions apply for the first indicator. For example the access will not work if the first indicator loads daily bars asynchronously or if it calls ChartControl without checking for null.
(3) The second indicator now can access the first one.
Let us have a look at a simple example. I will take the EMA.
The EMA has only one parameter, which is the period. So you would need to define a variable periodEMA to collect that value from the user.
Put PeriodEMA in the properties section accordingly.
Now that periodEMA exists and contains a value, you can access the indicator by calling it in OnBarUpdate():
The following 8 users say Thank You to Fat Tails for this post:
Just sitting down for the evening and it is too late to try to code my indicator this evening, but I can tell from your sample that it is pretty straight forward. I'll give it a try tomorrow morning. Thanks MUCH!
I purchased a system online and thankfully it was not a scam . That being said, I was interested in backtesting it using the strategy analyzer. The indicator that sets up the signals comes as a downloadable installer and I can't seem to be able to access it anywhere using the ninjascript editor. This may be the whole exposing attributes publicly issue pointed out previously.
It does however plot signals as it goes, so I was hoping to access the attributes of previous bars (ie. color), or the drawings (see the purple hashes in the attached img). Is this possible? This ninja forum says not, but I'd figure I should ask the good people here for some enlightenment.
You cannot edit a commercial indicator, but you can access the exposed values. To find out which are the exposed values, open the NinjaTrader editor, type the name of the indicator followed by a dot. For example for the SMA, you would type
You should then see the exposed DataSeries that you can access (and a lot of other junk as well). Or you ask the supplier of your commercial indicator, which of the values are exposed.
Don't know if this helps, but it's a little ditty I wrote a long time ago, creating a new indicator in which d9ParticleOscillator is referenced twice (14 period and 34 perod). Simple. It compares the 14 period raw trend to the 34 period raw trend and draws an arrow.