Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Trying to make selected MA type a drop down instead of numeric input
Collapse
X
-
Trying to make selected MA type a drop down instead of numeric input
Can someone help me to make the MA type a drop down instead of Numeric input. I'm just trying to streamline the setup of this MA Envelopes indicator I modified. I have a total of 15 different MA options available to the user.Tags: None
-
CS file work? Also, If you can walk me through the process, I'd really appreciate it.
I did something similar with Keltner channels but each MA type is in a different file. Came up with some interesting results by varying the time frame, type of chart, and look back period. Was hoping I could do something similar with Envelopes because they aren't so dependent on ATR calculationsAttached FilesLast edited by Conceptzx; 08-23-2023, 10:18 AM.
Comment
-
Done.
I've cleaned it up a bit,
re-factored the code some.
Change 'Name' to explicitly be 'MAEnv',
that way no naming conflicts ...

See attached.Attached Files
Comment
-
Use Google to study enum statements.Originally posted by bltdavid View PostI write up a few paragraphs to explain/describe the
new changes, and why I made them, later in the day.
As promised, here are some notes:
1. Use of My.Common namespace.
An enum declared in a separate namespace allows the identifier used
as the type name to also be used as a variable name. For ex, this may
look confusing, but you can actually do this kind of thing,
MAType MAType = MAType.EMA;
and, yes, this actually works, but only when the type MAType is defined
in a different namespace than the identifier MAType. And so, I setup the
My.Common namespace to hold the enum MAType and added the using
directive using My.Common to gain access to it. It's not a big deal, I
mean, you could use this code,
MAType maType = MAType.EMA;
and the difference in case for the variable name maType makes this kinda
moot, but I gain the ability to not care about this with this separate name
space trick. It's very common idiom in C# to see variables using the exact
same name (with same case) as the type name. For me, this duplicity, or
more correctly, this flexibility and freedom in the type vs variable naming
convention, when using sparingly and used well, can be very nice.
2. Removed class level MA typed variables.
I removed all the variables defined for each MA, and setup a C# switch
statement to access the current value of the current MA associated with
the value in the MAType property. One of the main reasons I did this in
this specific case is for simplicity, and because some of your MAs are not
included with NinjaTrader, so this switch statement allows me to comment
out just one line of code for each MA that is not available.
3. The MAType property type uses fully qualified My.Common.MAType.
This goes back to no. 1 above -- I always use the fully qualified type name
when defining a public enum property because whenever this indicator is
exported into a compiled assembly, you could have 'enum not found' issues
during the import process. I forget the exact error, but the solution is simple,
we fix these import problems by simply making the MAType public property
use the fully qualified enum type name in the public property definition.
Any questions, let me know.
Last edited by bltdavid; 08-23-2023, 03:01 PM.
- Likes 1
Comment
-
Hello Conceptzx,
There is a reference sample in the help guide on using an enum to select a moving average.
There is also an indicator that utilizes this as well.
Rewrite of the MACrossBuilder 1) Various Moving averages: DEMA, EMA, LinReg, HMA, SMA, TEMA, TMA, VWMA, WMA, ZLEMA 2) Various indication options 3) Can output to alerts window 4) Can output to Market Analyzer (+1, 0, ‐1 = Cross up, No cross, cross down) 5) Colors region between Moving averages V1.02 Update 10‐31‐17, minor code […]Chelsea B.NinjaTrader Customer Service
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
577 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment