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 RookieTrader, Today, 09:37 AM
            4 responses
            17 views
            0 likes
            Last Post RookieTrader  
            Started by PaulMohn, Today, 12:36 PM
            0 responses
            2 views
            0 likes
            Last Post PaulMohn  
            Started by love2code2trade, 04-17-2024, 01:45 PM
            4 responses
            38 views
            0 likes
            Last Post love2code2trade  
            Started by alifarahani, Today, 09:40 AM
            3 responses
            14 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by junkone, Today, 11:37 AM
            3 responses
            22 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X