View Full Version : Creating parameters for user input
NinjaTrader_Josh
07-15-2007, 01:15 AM
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
[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".
whitmark
07-15-2007, 09:16 AM
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
NinjaTrader_Ray
07-15-2007, 11:03 AM
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
07-15-2007, 11:23 AM
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.
NinjaTrader_Josh
07-15-2007, 12:57 PM
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.
whitmark
07-15-2007, 03:08 PM
Thanks Ray, for the quick turn on the answer and an example. Outstanding, and on Sunday too!
- Whitmark
SharkCub
07-30-2010, 05:27 PM
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?
mrlogik
07-31-2010, 06:32 AM
Shark,
Potential work around: make it a "NumberDecimal" input, where 0 is "auto", and anything else is the number of decimals?
SharkCub
07-31-2010, 06:36 AM
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.
mrlogik
07-31-2010, 06:49 AM
Assuming you're using NT7, (.NET 3.5) you can check this link (http://weblogs.asp.net/stefansedich/archive/2008/03/12/enum-with-string-values-in-c.aspx)out.
SharkCub
07-31-2010, 07:56 AM
Spent some time working with the suggested link. Here is another that was also helpful:
http://pietschsoft.com/post/2008/07/15/C-Enhance-Enums-using-Extension-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
snaphook
08-07-2010, 04:36 PM
I just posted BollingerPair to v7 indicators with the ability to select MA type from a drop down list.
Trader.Jon
08-11-2010, 05:02 PM
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
NinjaTrader_Bertrand
08-12-2010, 02:47 AM
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/forum/local_links_search.php?action=show&literal=1&search=optimize+weekday&desc=1