PDA

View Full Version : Moving Average of an Indicator


Joshua 1:8
06-10-2010, 02:02 PM
Hi,

Is there a way to plot a moving average of an indicator? Not Moving Average of price. For instance MACD. I would like to add a SMA of the MACD in the same pane. I know how to overlay, but I'm looking for an indicator that will plot this.

Thanks.
J

NinjaTrader_Tim
06-10-2010, 02:28 PM
Hi Joshua 1:8,

Thank you for your post.

With NinjaTrader 7, you can nest indicators, first selecting SMA, then using the MACD as the input series.

More info at - http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html
Under the "New Indicators on Indicators" section

Joshua 1:8
06-10-2010, 02:47 PM
That's what thats for!! (input series) LOL!

Thank you very much! Just what i was looking for!

J

zordan
08-30-2010, 03:20 PM
Hello, I am trying the following simple condition:

if (Range()[0] * VOL()[0] < SMA(Range() * VOL(), ma1)[0])

where ma1 is a lookback period, integer variable.

However I get an error message:
"Operator '*' cannot be applied to operands of type 'NinjaTrader.Indicator.Range' and 'NinjaTrader.Indicator.VOL'"

Could you clarify how to solve this?
I'd like the product of range and volume to be lower that its moving average.

Thanks for your help!

NinjaTrader_RyanM
08-30-2010, 04:01 PM
Hello Zordon,

The issue here is the expected input for your SMA indicator. It needs to be a data series.
See here for a tutorial on DataSeries. (http://www.ninjatrader-support.com/HelpGuideV6/Overview24.html)

DataSeries are:
1) Declared in Variables region
private DataSeries rangeTimesVol;

2) Instantiated in Initialize() method:
rangeTimesVol = new DataSeries (this);

3) Set in OnBarUpdate()
rangeTimesVol.Set(Range()[0] * VOL()[0]);

You can then use this as input for SMA:
if (Range()[0] * VOL()[0] < SMA(rangeTimesVol, ma1)[0])

zordan
08-30-2010, 04:46 PM
Thanks a lot.

When I put point 2 under section: protected override void Initialize()
rangeTimesVol = new DataSeries (this);

I get a bunch of errors:

Type expected
Class member declaration expected.
) expected.
Invalid token '=' in class, struct, or interface member declaration
Method must have a return type
Type expected

Could you help?




Hello Zordon,

The issue here is the expected input for your SMA indicator. It needs to be a data series.
See here for a tutorial on DataSeries. (http://www.ninjatrader-support.com/HelpGuideV6/Overview24.html)

DataSeries are:
1) Declared in Variables region
private DataSeries rangeTimesVol;

2) Instantiated in Initialize() method:
rangeTimesVol = new DataSeries (this);

3) Set in OnBarUpdate()
rangeTimesVol.Set(Range()[0] * VOL()[0]);

You can then use this as input for SMA:
if (Range()[0] * VOL()[0] < SMA(rangeTimesVol, ma1)[0])

NinjaTrader_RyanM
08-30-2010, 05:29 PM
Here's how it should look:


protected override void Initialize()
{
CalculateOnBarClose = true;
rangeTimesVol = new DataSeries (this);
}


You may have other items in Initialize, but make sure the statement is within the curly brackets { } of Initialize()