Currently I am having multiple public enums for my drawing tools / indicators, sometimes its even duplicated unnecessarily. I would prefer to have all enums placed at one location for better organization. What should be the correct location & format or example to have all enums in one place. Any help is appreciated!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Organize public enums
Collapse
X
-
Organize public enums
Hello,
Currently I am having multiple public enums for my drawing tools / indicators, sometimes its even duplicated unnecessarily. I would prefer to have all enums placed at one location for better organization. What should be the correct location & format or example to have all enums in one place. Any help is appreciated!Tags: None
-
Hello s.kinra,
Thanks for your question.
Similar to how we suggest using static methods in an a script in the AddOn folder for shared variables and methods, you can create an AddOn in the AddOn folder, but instead of making an AddOn, just include your enums in your enum custom namespace.
Let us know if there is anything else we can do to help!
-
Hello Jim,
Thanks for info. Can you please confirm if I need 2 separate namespaces for indicators & drawing tools, in your snapshot you're using namespace NinjaTrader.NinjaScript.Indicators.CustomEnumNames pace which believe is for indicators.
Comment
-
Hello s.kinra,
It really just depends on where the enums are created. They could simply reside in their own namespace, and you would just have to make sure that you add a using directive in your script to use the enums shorthand, or to use the fully qualified namespace in the scripts that use them.
In AddOn cs file:
In Indicator or Name-Your-NinjaScript cs file:Code:namespace MyEnums { public enum MyEnum1 { Item1, Item2, Item3, Item4, } }
Code:protected override void OnBarUpdate() { } private MyEnums.MyEnum1 EnumForThisScript; } }
Comment
-
Thanks Jim,
Adding 2 namespaces is working.
I am preferring adding my enums namespace in declaration (using MyEnums). Glad to confirm it works even with 1 namespace. I'll add my all enums this weekend & keep an option which is easily manageable.
Thanks again for help!
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
566 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
330 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
547 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
548 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment