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 05-08-2012, 07:00 PM   #1
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default Indicator with SMA

I want to make an indicator something like the Ninja MACrossBuilder indicator...but with 4 different moving averages (instead of 2) plotting.

I don't need to have the period, et cetera, selectable in the parameters...they would be fixed in the code as they don't change.

Any examples to look at?
Turtle Trader is offline  
Reply With Quote
Old 05-09-2012, 02:41 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Turtle Trader, I think you can take the template from Ryan here - http://www.ninjatrader.com/support/f...h=cross&desc=1

and then just dont expose the parameters as public properties, but instead hardcode their values into the method calls.

Of course you then also need to add extra plots as per your needs.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 05-09-2012, 03:04 AM   #3
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default reply

hi Bertrand,

That link does not go anywhere, can you repost it?

Thank you.
Turtle Trader is offline  
Reply With Quote
Old 05-09-2012, 03:12 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

The link goes to our sharing, which contains an MA cross builder shared by our RyanM, this could be a template for your works - http://www.ninjatrader.com/support/f...catid=4&id=426
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 05-09-2012, 03:18 AM   #5
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default reply

Hi Bertrand,

I clicked again and the link worked...search results. thank you.

Though, I'm a newbie a Ninja coder....can you give me an example of how to assign attributes, like Period, MA Type, et cetera, to a Plot in the code? And assign a DataSeries to a Plot?

I've read the MA Cross Builder and don't see where those are being applied...they are in the parameters but not assigned to the DataSeries in the code..?

And, how is a DataSeries applied to a Plot?

Is there a class I can take to know these things?

Thank you.
Turtle Trader is offline  
Reply With Quote
Old 05-09-2012, 03:28 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

If you're new to coding in NinjaScript, best would be checking through those tutorials for indicator coding we have prepared - http://www.ninjatrader.com/support/h.../tutorials.htm

Those would cover the basics needed for custom work and modifications.

The MA Builder code shared uses so called user defined inputs to set paramters - a tip in the education section explains those further - http://www.ninjatrader.com/support/f...ead.php?t=5782

If you just want to hardcode a period in, then assign the parameter in your MA method call for example - double mySMA = SMA(Close, 10)[0]; >> here the period is hardcoded to 10, there be no exposed user input dictating what is used, it will always be the coded in 10.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 05-09-2012, 10:19 AM   #7
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default thank you

thank you Bertrand
Turtle Trader is offline  
Reply With Quote
Old 05-09-2012, 10:29 AM   #8
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

You're welcome, if you run into any walls on this project please post and let us know.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 05-09-2012, 04:03 PM   #9
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default unable to get attached code to plot....

four SMAs in one indicator....probably a simple error....or left something out???

thank you!
Attached Files
File Type: zip test.zip (3.8 KB, 9 views)
Turtle Trader is offline  
Reply With Quote
Old 05-10-2012, 02:16 AM   #10
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Looks to be just a simple issue in your plot width assignments in the Initialize(), please try instead here -

Plots[0].Pen.Width = 2;
Plots[1].Pen.Width = 2;
Plots[2].Pen.Width = 2;
Plots[3].Pen.Width = 2;
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 05-10-2012, 09:10 AM   #11
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default where?

Hi Bertrand,

Yes, it appears the Pen.Width assignment should not be in the Initialize...but your message didn't state where to put them...

:-)

thank you.
Turtle Trader is offline  
Reply With Quote
Old 05-10-2012, 09:12 AM   #12
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

That's not the point, they can either go to OnStartUp() or Initialize(), but you've had incorrect index values assigned - so your last one pointed to a Plot array of 4 which does not exist > hence your issue loading the indicator, there was a corresponding Log tab entry noted by NT as well on it. If you use my version posted, it would work.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 05-10-2012, 09:19 AM   #13
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default I am an idiot!

come from a programming background where 0 is not a valid index....my brain was in two places...thank you!!

:-)
Turtle Trader is offline  
Reply With Quote
Old 05-10-2012, 09:20 AM   #14
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

No worries, glad to assist.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 05-10-2012, 09:22 AM   #15
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default ....

Next time I'm in Berlin I will buy you a beer...
Turtle Trader 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
Discrepancy between plotted SMA and Indicator SMA? Bogomir28 Indicator Development 2 03-24-2012 03:49 PM
SMA Indicator ryebank General Programming 1 07-05-2011 03:52 AM
Directing SMA of Indicator to the Indicator panel oz-dog Automated Trading 4 06-16-2011 06:34 AM
indicator to plot the 50 period sma of the 5 sma brdnickel NinjaScript File Sharing Discussion 6 01-26-2011 01:03 PM
SMA of an indicator erinys Indicator Development 3 12-20-2009 01:08 PM


All times are GMT -6. The time now is 06:40 AM.