Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

public enum myType

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

    public enum myType

    Does anyone know how to make an enumeration type private to a Ninja script?

    With NT7 enum could be defined within the indicator class in the region "variables".

    public enum myType { }

    A renamed copy of the indicator could be produced without any problem.


    With NT8, enum needs to be defined outside the NameSpace and outside of the indicator class. So it is truly public. When a renamed copy of the indicator is created, an error is produced that the myType is already defined. This requires renaming myType so it is unique for each indicator.

    What I want is an enumeration type that is private to the Ninja script, but I don't know how to produce it. Any assistance or code examples would be appreciated.

    #2
    I place my enums in their own script to make them available to all indicators. In this way, copying an indicator that uses an existing enum does not need to rename it.

    Comment


      #3
      Hi Camdo,

      Enums should be outside of the class of the indicator and outside of the NinjaTrader namespace.

      Below is a link to the reference sample on using enums.


      tradesmart's advice is sound if you would like to use the enums for multiple scripts.
      I also recommend putting these in your own namespace to prevent conflicts with other developers who may by change use the same enum names.

      Last, below is a link to an advanced script that modifies the descriptions for enums.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        I understand that enums should be outside of the class of the indicator and outside of the NinjaTrader namespace.

        Should I use a separate namespace for containing the enum (as you recently did) or simply follow the sample provided here

        http://ninjatrader.com/support/forum...ead.php?t=3420

        and not use an additional namepsace.

        What is the difference?

        Comment


          #5
          Hello Harry,

          This is your preference.

          I add my enums to a custom namespace so that they do not cause conflicts with anyone else who happens to make a script that uses the same enum names. (Just by chance I have seen two developers use the same enum name and didn't place this in a custom namspace so the scripts conflicted and only one could be imported at a time)
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_ChelseaB View Post
            Hello Harry,

            This is your preference.

            I add my enums to a custom namespace so that they do not cause conflicts with anyone else who happens to make a script that uses the same enum names. (Just by chance I have seen two developers use the same enum name and didn't place this in a custom namspace so the scripts conflicted and only one could be imported at a time)
            I have also seen this and will consider using namespaces in future.

            Thank you for your answer.
            Last edited by Harry; 12-11-2017, 03:05 PM.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            57 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            37 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            18 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            20 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            49 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X