• 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 levikNT, Today, 04:39 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by chartish, Today, 08:36 AM
    2 responses
    14 views
    0 likes
    Last Post chartish  
    Started by login_dejavu, Yesterday, 04:58 AM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_RyanS  
    Started by NinjaTrader_PaulH, Today, 07:40 AM
    0 responses
    4 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by awesometrader, Today, 06:59 AM
    2 responses
    9 views
    0 likes
    Last Post awesometrader  
    Working...
    X