NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 06-05-2010, 01:31 PM   #1
stasbz
Junior Member
 
Join Date: Jun 2010
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default help! simple indicator with sma. how to write!

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
Last edited by stasbz; 06-05-2010 at 01:40 PM.
stasbz is offline  
Reply With Quote
Old 06-05-2010, 06:23 PM   #2
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

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.
NinjaTrader_Brett is offline  
Reply With Quote
Old 06-05-2010, 07:31 PM   #3
mrlogik
Certified NinjaScript Consultant
 
mrlogik's Avatar
 
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
Default

stasbz,

You are passing in a value. You need to pass in a dataseries.

Create a dataseries like this.

Code:
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.
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"

PureLogikTrading
mrlogik is offline  
Reply With Quote
Old 06-06-2010, 06:04 PM   #4
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Thanks for the assist Mr. Logik.

Let me know if I can be of further assistance.
NinjaTrader_Brett is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SMA efficiency dave1992 Indicator Development 1 05-29-2010 08:25 AM
How to write simple indicator? jim c Indicator Development 1 03-31-2010 12:47 PM
Trying to write a 'divergence' indicator DancesWithBears Indicator Development 2 07-29-2009 08:47 PM
Looking for someone to write a simple indicator for me pclark Indicator Development 2 09-06-2008 11:05 PM
How to write new indicator? jcrecruit Indicator Development 4 10-19-2007 03:36 AM


All times are GMT -6. The time now is 02:03 PM.