![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
|
hi Bertrand,
That link does not go anywhere, can you repost it? Thank you. |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
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
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
|
thank you Bertrand
|
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
You're welcome, if you run into any walls on this project please post and let us know.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
|
four SMAs in one indicator....probably a simple error....or left something out???
thank you! |
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
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;
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Senior Member
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#12 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Senior Member
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
|
come from a programming background where 0 is not a valid index....my brain was in two places...thank you!!
:-) |
|
|
|
|
|
#14 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
No worries, glad to assist.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#15 |
|
Senior Member
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
|
Next time I'm in Berlin I will buy you a beer...
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |