Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Polluting the global namespace

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

    Polluting the global namespace

    I use enums for some user parameters. The problem is that the AutoMagic code that is generated needs to see them, because they are part of the constructors' signatures.

    Putting them in NinjaTrader.Indicator would be bad enough, but that fails to solve the problem (even with a "using" declaration -- accessibility conflicts).

    The bottom line is that I have found no way to make that compile (V7) other than to put them in the global namespace.

    OK -- please tell me how I should be doing it. Requiring me to pollute the global namespace is pretty bad, so there must be a better way that I am missing. What is it?

    --EV

    P.S. I am new enough to have no experience with V6. However, from what I have seen, this issue is new with V7. I can only assume that the AutoMagic code is significantly different in V7.

    #2
    EV, for using enums, please work alongside this reference sample here - http://www.ninjatrader.com/support/f...ead.php?t=3420

    The enum itself should reside outside the Indicator namespace as shown.

    Comment


      #3
      Right. In fact, that is the sample I used to learn about enum parameters. I know how to do it and mechanically it works just fine.

      Something about it changed in V7, though. That V6 code that I got the other day that would not compile for me (Adaptive_CCI) had its enum in the class. Once I moved it outside everything it compiled fine. That's why I infer there was a V7 change.

      The problem I am bringing up is a software engineering thing -- it would be best if my enums were per-indicator, or limited to all of my custom indicators, whichever I choose. As far as I can see, there is no way to do that and have the compiler enforce it.

      That means that all programmers and/or vendors are putting whatever symbols they want into one common space. Sooner or later there will be a collision. Yes, I know that I can adopt a naming convention for mine, such as a (presumably) unique prefix, to keep mine separate (simply because it will be unlikely for anyone else to choose the same name).

      I have done so, but from a software engineering point of view that is kind of passe. It really would be better if the AutoMagic code were set up so that it did not force my enums into the global namespace.

      --EV

      Comment


        #4
        Thanks for the suggestions - I'm not aware of design changes 6.5 vs 7 in this aspect, the reference sample we published actually dates back to 6.5 times.

        Comment


          #5
          You are welcome.

          As to V7 changing -- I am basing that on the assumption that Adaptive_CCI compiled fine in V6. I do not know that for a fact, though.

          Look at it this way -- that's an important aspect of namespaces -- the ability to keep one's symbols from colliding with those from other programmers and/or vendors, even in mixed environments with no prior consultation or agreements. As long as everyone uses from the system space, but only creates in his own namespaces then it all works fine.

          As of V7, the AutoMagic code foils that -- it would be good if someone could figure out how to do your nice magic stuff while keeping each indictor's symbols partitioned.

          --EV

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          579 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 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
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X