Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enum/Namespace conflicts

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

    Enum/Namespace conflicts

    Hi. Whenever I duplicate my indicator to work on a new version I have always have to change the name of the namespace which contains the ENUMS.

    If I don't I get an error when compiling. Is this normal? 2 indicators cannot have the same namespace?

    Changing the name manually does not update the ninjascript code which you're not supposed to touch It's no big deal but I wondered if I'm doing something wrong but it's a bit annoying having to change the code and do a find and replace every time I duplicate a file.

    See screenshots.


    #2
    Hello lucyb,

    You should only have a single namespace statement in a code file. See the attached image.

    Click image for larger version

Name:	image.png
Views:	166
Size:	70.0 KB
ID:	1332345

    As you can see (the screenshot is from Visual Studio), you can add a custom name to the existing NT namespace to hold your indicators.

    When I go to duplicate a file, I open a NinjaScript Editor window and open the file to duplicate. Without changing any code, I do a Save As... with the new name. The NinjaScript Editor will then rename key parts of the code for you. In some cases, you may need to make additional changes for it to compile.

    Hope that helps!
    Matt

    Comment


      #3
      Hello lucyb,

      What you are seeing is correct, when you make a duplicate of an indicator the duplicate needs a unique classname. Your enum will also need to define a new class name so it is not a conflict, you can continue to use the same namespace as you were in the original file but the enum its self needs renamed and the code that uses it in the new file needs updated to reflect that new name.

      The SaveAs will only work for the indicators class name and Name = "" string, that will not work for more advanced items like custom namespaces or enums so your script will need some manual changes each time you make a copy of it.

      Comment

      Latest Posts

      Collapse

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