• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 Arkadiy_B, Today, 06:43 AM
    0 responses
    2 views
    0 likes
    Last Post Arkadiy_B  
    Started by leontancfa, Today, 06:09 AM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_PatrickG  
    Started by soulfx, 12-01-2017, 08:44 AM
    3 responses
    1,019 views
    0 likes
    Last Post NinjaTrader_EricB  
    Started by Parmenides48, 04-09-2019, 03:32 AM
    10 responses
    53 views
    0 likes
    Last Post NinjaTrader_PatrickG  
    Started by NinjaCustomer, Today, 01:48 AM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_EricB  
    Working...
    X