View Full Version : Putting verbiage in Indicator selection
photog53
05-23-2010, 02:16 PM
I have code that selects various moving averages from the Indicator. Right now I select a number (int) and then use the MA identified with that selection.
.....See code below
[Description("1=EMA 2=SMA 3=WMA 4=HMA 5=ZLEMA 6=TEMA 7=TMA 8=VWMA 9=ADXVMA")]
[GridCategory("Parameters")]
public int SlowMA
{
get { return slowMA; }
set { slowMA = Math.Max(1, value); }
}
.....see attached .png file for the visual
I'd like to have the actual letters ("EMA' SMA, etc,) show up in the selection instead of simply choosing a number. Is there a way to do that?
Thanks......................
NinjaTrader_Ben
05-23-2010, 08:30 PM
Hello,
I believe you want to do an enum method. Please go here for details on this:
http://www.ninjatrader.com/support/forum/showthread.php?t=3420
If that doesn't cover it, please let me know.
photog53
05-24-2010, 08:16 AM
Thanks!!!
....(as always a fast helpful response)
I'll take a look......
photog53
05-24-2010, 09:08 AM
Oh my gosh....that works GREAT!!!
Thanks......
photog53
05-24-2010, 09:59 AM
Ooopss.... Next Question.....
I have two plot lines.....(Fast & slow). I successfully set up both enums and have two Moving average cases, but I'm having trouble getting the correct Moving average value set with the appropriate plot line.
NinjaTrader_RyanM
05-24-2010, 10:13 AM
Hello photog53,
Can you share some of the code you're working with so we can see what might be causing this? Can also attach the .cs file found in 'Documents\NinjaTrader\bin\custom\indicator'.
photog53
05-24-2010, 11:28 AM
Certainly....(should have done that sooner) :)
NinjaTrader_Bertrand
05-24-2010, 11:42 AM
You will need to setup more cases, you only have it defined for the enum to be the EMA choice hence it only works for this then.
photog53
05-24-2010, 12:10 PM
Got it.......(a bit of trial and error helped me understand your suggestions)
As always....GREAT ASSISTANCE!!!!!!
....corrected code
switch (fastMA)
{
case UniversalFastMA.EMA: {FastLine.Set (EMA(fastPeriod)[0]); break; }
case UniversalFastMA.SMA: {FastLine.Set (SMA(fastPeriod)[0]); break;}
case UniversalFastMA.WMA: {FastLine.Set (WMA(fastPeriod)[0]); break;}
case UniversalFastMA.HMA: {FastLine.Set (HMA(fastPeriod)[0]); break;}
case UniversalFastMA.ZLEMA: {FastLine.Set (ZLEMA(fastPeriod)[0]); break;}
case UniversalFastMA.TEMA: {FastLine.Set (TEMA(fastPeriod)[0]); break;}
case UniversalFastMA.TMA: {FastLine.Set (TMA(fastPeriod)[0]); break;}
case UniversalFastMA.VWMA: {FastLine.Set (VWMA(fastPeriod)[0]); break;}
case UniversalFastMA.DEMA: {FastLine.Set (DEMA(fastPeriod)[0]); break;}
case UniversalFastMA.EhlersFilter: {FastLine.Set (EhlersFilter(fastPeriod)[0]); break;}
}
--------------Earlier message----------------
Apologies....but I didn't quite understand your suggestion.
(I am still learning C#....so my understanding of basic syntax is not great)
Did I mess up the default value.....or do I have to add a "case" for each MA type
/ -------------------- Fast MA Case Function --------------------------------
switch (fastMA)
{
case UniversalFastMA.EMA:
{
FastLine.Set (EMA(fastPeriod)[0]);
break;
}
case UniversalFastMA.SMA:
FastLine.Set(SMA(fastPeriod)[0]);
break;
}
case UniversalFastMA.WMA:
{
FastLine.Set(WMA(fastPeriod)[0]);
break;
}
etc.................
Also this version of my code does not plot the second moving average line (slowLine). Not sure what I did wrong there.
Thanks for the help!!!!
NinjaTrader_RyanM
05-24-2010, 01:22 PM
You don't have to add a case for every MA type, but you should add a case for every type that you've defined in your enum.
There won't be any difference with the implementation fast/slow. Whatever you did on the fast line, duplicate for the slow.