• 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

Creating a Utilities folder

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

    Creating a Utilities folder

    I have a number of shared Functions or Methods that I use in a number of different indicators and strategies. I was hoping that adding a folder into the Class hierarchy would be as easy as creating that folder. But alas...

    Could someone guide me toward how to create this setup?

    Would be a useful thing if NT did this by default.

    #2
    Hello RandyT,

    Thanks for your post.

    We typically advise to create shared methods in a separate file and then to create partial classes for your indicator or strategy based shared methods. You may also add code to the AddOn namespace or your own namespace as well. The NinjaScript that calls these methods will then need to reference the shared methods with the fully qualified namespace or add a using directive for that namespace to find the methods.

    For example, code within:

    Code:
    namespace NinjaTrader.NinjaScript.AddOns.MySharedMethods
    {
    	public void MyMethod()
    	{}
    Will have to be referenced like:

    Code:
    NinjaTrader.NinjaScript.AddOns.MySharedMethods.MyMethod();
    or

    Code:
    using NinjaTrader.NinjaScript.AddOnsMySharedMethods;
    
    ...
    
    MyMethod();
    Creating a new folder does not create a new namespace, this will have to be added to the script.

    An example for shared methods that we have shared previously can be found below.

    Shared Methods example: https://ninjatrader.com/support/foru...104#post457104

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by simjs, Yesterday, 08:11 PM
    0 responses
    3 views
    0 likes
    Last Post simjs
    by simjs
     
    Started by mrlucky1x, Yesterday, 06:01 PM
    0 responses
    3 views
    0 likes
    Last Post mrlucky1x  
    Started by dedouglas, Yesterday, 03:17 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Jugado, Yesterday, 02:22 PM
    2 responses
    30 views
    0 likes
    Last Post Jugado
    by Jugado
     
    Started by login_dejavu, 04-21-2019, 04:58 AM
    2 responses
    24 views
    0 likes
    Last Post login_dejavu  
    Working...
    X