In the "Miscellaneous practices" section of the "NinjaScript Best Practices" web page, the subsection titled "Creating user defined parameter types / enums" states:
"When creating enums for your NinjaScript objects, it is strongly suggested to define those outside the class (emphasis is my own) and in a custom namespace. A reference sample providing all details could be found here." where the "found here" link is to the "Creating a user-defined parameter type (enum)" code example at https://ninjatrader.com/support/help...ned_parame.htm
Why is it strongly suggested to define enums outside of a NinjaScript Strategy that uses it?
Could anything bad happen if an enum was defined as a nested type of a Strategy?
I ask because I have multiple Strategies where the "same" enum (for example an enum that contains the 12 months of the year, which are exact copies of each other) is defined as a nested type of each of the Strategies, and since each of the enums are nested types of separate Strategies, they are unique types and so won't cause a compilation error due to the same enum being defined multiple times. Furthermore, I can share all of these strategies with other people without them getting a compilation error that either says that the enum type is missing or that the enum type is defined multiple times. In other words, defining enums as nested types of Strategies has the advantage that it makes the Strategies easy to deploy, since every nested enum type is guaranteed to always be defined exactly once.
Thanks in advance!
EquityTrader
Comment