![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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); }
}
Last edited by NinjaTrader_Josh; 07-15-2007 at 01:17 AM.
|
|
|
|
|
|
#2 |
|
Certified NinjaScript Consultant
|
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 |
|
|
|
|
|
#3 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
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
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
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
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
|
|
|
|
|
|
#6 |
|
Certified NinjaScript Consultant
|
Thanks Ray, for the quick turn on the answer and an example. Outstanding, and on Sunday too!
- Whitmark |
|
|
|
|
|
#7 |
|
Junior Member
|
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? |
|
|
|
|
|
#8 |
|
Certified NinjaScript Consultant
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
|
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 |
|
|
|
|
|
#9 |
|
Junior Member
|
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. |
|
|
|
|
|
#10 |
|
Certified NinjaScript Consultant
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
|
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 |
|
|
|
|
|
#11 |
|
Junior Member
|
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 |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Apr 2008
Posts: 376
Thanks: 0
Thanked 20 times in 11 posts
|
I just posted BollingerPair to v7 indicators with the ability to select MA type from a drop down list.
|
|
|
|
|
|
#13 | |
|
Senior Member
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
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 |
|
|
|
|
|
|
#14 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,547
Thanks: 261
Thanked 1,012 times in 993 posts
|
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
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |