NinjaTrader Support Forum  

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 07-15-2007, 01:15 AM   #1
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default Creating parameters for user input

I am trying to create an indicator that lets me easily switch between using either an EMA or a SMA for calculations.

I want to have it as one of the parameters options when I add it to the chart. Something like
Code:
[Description("Period for third SMA line. (Numbers of bars used for calculations)")]
        [Category("Parameters")]
        public int SMA3
        {
            get { return sma3; }
            set { sma3 = Math.Max(1, value); }
        }
but maybe instead of inputting an int I can choose from a dropdown menu or at least type "sma" or "ema".
Last edited by NinjaTrader_Josh; 07-15-2007 at 01:17 AM.
NinjaTrader_Josh is offline  
Reply With Quote
Old 07-15-2007, 09:16 AM   #2
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default

Good suggestion uacvax . . . I would also suggest the capablity for pull down values that would accommodate values like

"1 - SMA"
"2 - EMA"
"3 - HMA"

Where parameter inputs, in particular for strategies, would be indifferent between the input of a "1" or "1 - SMA". In this way, the optimizer can be used to iterate numeric input values while the user can select more meaningful predetermined input values.

Regards,

Whitmark
whitmark is offline  
Reply With Quote
Old 07-15-2007, 11:03 AM   #3
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

You can do this now, just declare an enum outside of the class declaration in your indicator/strategy.

http://www.csharp-station.com/Tutorials/Lesson17.aspx
NinjaTrader_Ray is offline  
Reply With Quote
Old 07-15-2007, 11:23 AM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default Reference Sample

Attached is a sample indicator demonstrating this concept.

Import the file via File > Utilities > Import NinjaScript. Then take a look at the source code as a reference.
Attached Files
File Type: zip MyMovingAverage.zip (6.5 KB, 94 views)
NinjaTrader_Ray is offline  
Reply With Quote
Old 07-15-2007, 12:57 PM   #5
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Great! Thanks Ray. I remembered something similar to that in a programming class I took many years ago just couldn't remember what it was called.
NinjaTrader_Josh is offline  
Reply With Quote
Old 07-15-2007, 03:08 PM   #6
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default

Thanks Ray, for the quick turn on the answer and an example. Outstanding, and on Sunday too!

- Whitmark
whitmark is offline  
Reply With Quote
Old 07-30-2010, 05:27 PM   #7
SharkCub
Junior Member
 
Join Date: Jul 2010
Location: Pittsburgh
Posts: 13
Thanks: 0
Thanked 1 time in 1 post
Send a message via AIM to SharkCub Send a message via Skype™ to SharkCub
Default How to do pull-down for text list?

I would like to do a pull-down for the following list of text to be selected by the user:

"auto"
"0"
"0.00"
"0.000"
"0.0000"
"0.00000"

(Essential number formats for displaying information).

These CANNOT be used as "enums" - illegal. Any suggestions?
SharkCub is offline  
Reply With Quote
Old 07-31-2010, 06:32 AM   #8
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

Shark,

Potential work around: make it a "NumberDecimal" input, where 0 is "auto", and anything else is the number of decimals?
"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 07-31-2010, 06:36 AM   #9
SharkCub
Junior Member
 
Join Date: Jul 2010
Location: Pittsburgh
Posts: 13
Thanks: 0
Thanked 1 time in 1 post
Send a message via AIM to SharkCub Send a message via Skype™ to SharkCub
Default

I have been using that "hack"

_auto
_0
_0_0
_0_00
_0_000
_0_0000

Just not very satisfying. Seems like there should be a better way.
SharkCub is offline  
Reply With Quote
Old 07-31-2010, 06:49 AM   #10
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

Assuming you're using NT7, (.NET 3.5) you can check this link out.
"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 07-31-2010, 07:56 AM   #11
SharkCub
Junior Member
 
Join Date: Jul 2010
Location: Pittsburgh
Posts: 13
Thanks: 0
Thanked 1 time in 1 post
Send a message via AIM to SharkCub Send a message via Skype™ to SharkCub
Default

Spent some time working with the suggested link. Here is another that was also helpful:

http://pietschsoft.com/post/2008/07/...n-Methods.aspx

In both instances, NT7 displays the enum string in the drop list. These extension methods provide a mechanism for converting the enum to the string.

Generic lists made for interesting display - apparently a way that COULD be used to create a list of stock symbols, add to or remove them... But did not see a way to return an index of an item:

http://msdn.microsoft.com/en-us/library/0ebtbkkc.aspx
SharkCub is offline  
Reply With Quote
Old 08-07-2010, 04:36 PM   #12
snaphook
Senior Member
 
Join Date: Apr 2008
Posts: 376
Thanks: 0
Thanked 20 times in 11 posts
Default

I just posted BollingerPair to v7 indicators with the ability to select MA type from a drop down list.
snaphook is offline  
Reply With Quote
Old 08-11-2010, 05:02 PM   #13
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Ray View Post
Attached is a sample indicator demonstrating this concept.

Import the file via File > Utilities > Import NinjaScript. Then take a look at the source code as a reference.
Ray,

Can you show us (as in me, the code writer challenged minority) how that indicator would be integrated into a strategy, so it (MAType) could be used in optimization?

NT7 would be good, since we are driving that way

Thanks,
Jon
Trader.Jon is offline  
Reply With Quote
Old 08-12-2010, 02:47 AM   #14
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,547
Thanks: 261
Thanked 1,012 times in 993 posts
Default

TraderJon, you can take a look at the dayOfWeek optimizer script Ryan has posted in our sharing, you can optimize an Int input which is 'linked' to the day fo week to trade on, the same concept can be used to switch through the MA's for your strategy -

http://www.ninjatrader.com/support/f...weekday&desc=1
NinjaTrader_Bertrand 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
Increase number of New Indicator Input Parameters??? higler General Programming 5 10-12-2011 04:13 PM
Your input? trade options, following many strikes? curt504 Strategy Development 1 06-10-2007 06:02 PM
Using a formula or variable as an input to an Indicator nolantx Indicator Development 5 05-24-2007 03:58 PM
Is it possible to define sub category or user define category for parameters theperm Strategy Development 7 05-16-2007 08:48 AM
user settable input set incorrectly? Folls General Programming 1 05-10-2007 09:39 AM


All times are GMT -6. The time now is 01:55 AM.