View Full Version : Recalling Function in Indicators
How can I recall the built-in indicators in a customized indicator?
For example if I want to use the Exponential Moving Average in a new indicator, how can I do it?
Thanks for any answers.
NinjaTrader_Ray
11-02-2006, 04:54 AM
Max,
Please see this link - http://www.ninjatrader-support.com/HelpGuide/MovingAverageEMA.html
Ray
I've seen the example and works correcltly, nevertheless I've got a problem to use EMA with my function.
EX:
double value = EMA(Close,Period)[0];
double value2 = EMA(value,Period)[0];
There is an error on the second string.
Does the function accept any parameter?
NinjaTrader_Ray
11-02-2006, 05:30 AM
Thanks for the example, no the function only accepts input in the form of an ojbect that implements the IDataSeries interface.
Basically, it only accepts a DataSeries as input.
Input;
High;
Low;
Close;
Volume;
Indicator; etc...
You can createa custom dataseries and pass that value in.
Createa variable under the Variables section.
private IndicatorSeries mySeries;
In the Initialize() method:
mySeries = new IndicatorSeries(this);
In the OnBarUpdate():
mySeries.Set(EMA(Close, Period)[0]);
double value2 = EMA(mySeries, Period)[0];
Alternatively you can do this:
double value2 = (EMA(EMA(Close, Period), Period)[0];
It doesn't work.
In both cases I've got always the same value and the same plot.
There is no difference between:
double value = EMA(Close,Period)[0];
and
double value1 = EMA(EMA(Close, Period), Period)[0];
neither following the DataSeries example.
NinjaTrader_Ray
11-02-2006, 06:08 AM
Max,
I can't comment on why you would see two different values since I can't see your entire code however, if you look at the attached sample, you will note that two different values are generated and plotted on a chart.
Ray
How can I open your attachment?
NinjaTrader_Ray
11-02-2006, 06:24 AM
It's a zip file. Just click on the link to download it to your PC. Then click on the file to extract the contents.
I know, I mean how to read a .cs file.
Must I import the file into a folder in Ninja?
NinjaTrader_Ray
11-02-2006, 06:38 AM
Copy the file to C:\Program Files\NinjaTrader 5\bin\custom\indicator
You can then open it via Tools-->EditNinjaScript and compile, then add to a chart.
Ray