Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exporting code in custom namespaces

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

    Exporting code in custom namespaces

    Hi,

    Is there a way to introduce my own namespaces into the Ninjatrader solution and still export my code? When writing my own code, if I separate the code into its own file (say for example a volume data manager singleton in its own file in the solution) with its own namespace, everything compiles and runs fine within Ninjatrader. I just add the normal using statement at the top of the classes that use this new class. The new file is picked up, the solution compiles and everything runs fine and works perfectly. I can even see the new file in the NinjaScript Editor.

    When I try to export this though I get a compilation error that the new namespace cannot be resolved. How does the export compile differently to just plain compiling in the NinjaScript Editor?

    EDIT: Just as an aside, if I move the custom class into one of the Ninjascript namespaces like NinjaTrader.NinjaScript.Indicators for example, the code exports without a problem.

    Thanks for any help,
    John
    Last edited by JohnSteinberg; 11-26-2016, 03:47 AM.

    #2
    Hello,

    Thank you for the post.

    Generally for exporting items you should use the fully qualified name rather than using statements.

    If you declare your own namespace:

    Code:
    namespace MyNamespace{  }
    Rather than having a using MyNamespace; at the top of the script, wherever you use something from that namespace type it out:

    Code:
    Mynamespace.MyEnum.MyEnumValue
    This pattern should allow you to export items with more complex structure. I am unsure of the difference internally on how this corrects the export but it does. There can also be other items with compiled assemblies that come up, here is one page that will contain that information as it is updated: http://ninjatrader.com/support/helpG...assemblies.htm

    Attached is a sample that uses an enum from a custom namespace as a NinjaScript property.

    I look forward to being of further assistance.
    Attached Files

    Comment


      #3
      Working thanks

      Hi Jesse,

      Thanks for the reply. This works for exporting code.

      Regards,
      John

      Comment

      Latest Posts

      Collapse

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