Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Organize public enums

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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!

    #2
    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!
    Attached Files

    Comment


      #3
      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.
      Last edited by s.kinra; 08-06-2021, 08:12 AM. Reason: missed the follow on question

      Comment


        #4
        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,
            }
        }
        In Indicator or Name-Your-NinjaScript cs file:
        Code:
                protected override void OnBarUpdate()
                {
        
                }
        
                private MyEnums.MyEnum1 EnumForThisScript;
            }
        }

        Comment


          #5
          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
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X