View Full Version : help! simple indicator with sma. how to write!
stasbz
06-05-2010, 01:31 PM
please. could you help to write indicator correctly
formula of indicator: moving average ( abs( Close - Open), any period)
i wrote SMA(Math.Abs(Close - Open)), Period) [0]
and get error NT0019
NinjaTrader_Brett
06-05-2010, 06:23 PM
Hello,
Thank you for your first forum post!
Can you please let me know what error you received and also post the section of the code that the error message indicates has an error.
I look forward to assisting you further.
mrlogik
06-05-2010, 07:31 PM
stasbz,
You are passing in a value. You need to pass in a dataseries.
Create a dataseries like this.
private DataSeries sAbs;
protected override void Initialize()
{
sAbs = new DataSeries(this);
}
protected override void OnBarUpdate()
{
sAbs.Set(Open[0] - Close[0]);
double smaValue = SMA(sAbs, Period)[0];
}
Hope this helps.
NinjaTrader_Brett
06-06-2010, 06:04 PM
Hello,
Thanks for the assist Mr. Logik.
Let me know if I can be of further assistance.