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!
See more
See less

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
    JimNinjaTrader Customer Service

    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;
            }
        }
        JimNinjaTrader Customer Service

        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 cmtjoancolmenero, Yesterday, 03:58 PM
          9 responses
          35 views
          0 likes
          Last Post cmtjoancolmenero  
          Started by DayTradingDEMON, Today, 09:28 AM
          4 responses
          21 views
          0 likes
          Last Post DayTradingDEMON  
          Started by geddyisodin, Yesterday, 05:20 AM
          9 responses
          50 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by George21, Today, 10:07 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Started by Stanfillirenfro, Today, 07:23 AM
          9 responses
          24 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X