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

confused about the namespace of addons

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

    confused about the namespace of addons

    Hi,

    I see some sample addon classes inheriting from NinjaTrader.NinjaScript.AddOnBase declared in different namespaces. Sometimes:
    Code:
    NinjaTrader.Custom.AddOns
    Sometimes:
    Code:
    NinjaTrader.Gui.NinjaScript
    Sometimes:
    Code:
    NinjaTrader.NinjaScript.AddOns
    I thought the namespace is required because there is additional code generated by the NT compiler. Up until now, whenever I port code from some sample, I have ignored this discrepancy as long as the code compiled.
    1. When exactly does it matter to use the required namespace? I presume only when the code is to be compiled by NinjaTrader. Otherwise, if the code is going to be compiled into a referenced assembly, it can be any CLR-compliant namespace. For example, I created a whole lib in
      Code:
      NinjaTrader.NinjaScript.AddOns.Utils
      but I would like to change its namespace before compiling the release.
    2. Which one of these namespaces is the correct one?

    #2
    Hello xcondor,

    Thank you for the post.

    In this situation, I believe this is just due to the nature of addons not really requiring a specific namespace for addons. The default namespace that NinjaTrader recommends is NinjaTrader.NinjaScript.AddOns.

    The NinjaTrader.Custom.AddOns is suggested by visual studios intellesense so perhaps some users auto correct to this.

    I see NinjaTrader.Gui.NinjaScript in our addon sample, so that is likely where this comes from. This was likely used because of the other using statements required and the way the code was written. Changing the namespace of this addon breaks it and you would need to correct some errors.

    The platform doesn't really look at the namespace specifically it will load an addon as long as it is actually an addon inheriting from :AddonBase.

    You can also see other misc files in the addon folder, that is generally the suggested place to put random C# files or classes you may call on.

    You are free to change namespaces as you wish, but please test that your script still works and exports as intended if you do.

    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 06-01-2018, 03:28 PM.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by sidlercom80, 10-28-2023, 08:49 AM
    168 responses
    2,262 views
    0 likes
    Last Post sidlercom80  
    Started by Barry Milan, Yesterday, 10:35 PM
    3 responses
    10 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by WeyldFalcon, 12-10-2020, 06:48 PM
    14 responses
    1,429 views
    0 likes
    Last Post Handclap0241  
    Started by DJ888, 04-16-2024, 06:09 PM
    2 responses
    9 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    41 views
    0 likes
    Last Post jeronymite  
    Working...
    X