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

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.
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        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 Waxavi, Today, 02:10 AM
          0 responses
          3 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by TradeForge, Today, 02:09 AM
          0 responses
          7 views
          0 likes
          Last Post TradeForge  
          Started by Waxavi, Today, 02:00 AM
          0 responses
          2 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by elirion, Today, 01:36 AM
          0 responses
          4 views
          0 likes
          Last Post elirion
          by elirion
           
          Started by gentlebenthebear, Today, 01:30 AM
          0 responses
          4 views
          0 likes
          Last Post gentlebenthebear  
          Working...
          X