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
    JesseNinjaTrader Customer Service

    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 Tim-c, Today, 03:54 AM
      0 responses
      3 views
      0 likes
      Last Post Tim-c
      by Tim-c
       
      Started by FrancisMorro, Today, 03:24 AM
      0 responses
      2 views
      0 likes
      Last Post FrancisMorro  
      Started by Segwin, 05-07-2018, 02:15 PM
      10 responses
      1,772 views
      0 likes
      Last Post Leafcutter  
      Started by Rapine Heihei, 04-23-2024, 07:51 PM
      2 responses
      31 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by Shansen, 08-30-2019, 10:18 PM
      24 responses
      945 views
      0 likes
      Last Post spwizard  
      Working...
      X