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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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!JimNinjaTrader Customer Service
-
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:
Code:namespace MyEnums { public enum MyEnum1 { Item1, Item2, Item3, Item4, } }
Code:protected override void OnBarUpdate() { } private MyEnums.MyEnum1 EnumForThisScript; } }
JimNinjaTrader Customer Service
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 cmtjoancolmenero, Yesterday, 03:58 PM
|
9 responses
35 views
0 likes
|
Last Post Today, 11:02 AM | ||
Started by DayTradingDEMON, Today, 09:28 AM
|
4 responses
21 views
0 likes
|
Last Post Today, 10:47 AM | ||
Started by geddyisodin, Yesterday, 05:20 AM
|
9 responses
50 views
0 likes
|
Last Post Today, 10:45 AM | ||
Started by George21, Today, 10:07 AM
|
1 response
12 views
0 likes
|
Last Post Today, 10:43 AM | ||
Started by Stanfillirenfro, Today, 07:23 AM
|
9 responses
24 views
0 likes
|
Last Post Today, 10:16 AM |
Comment