• 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

  • RandyT
    started a topic Creating a Utilities folder

    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.

  • NinjaTrader_Jim
    replied
    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.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by Hanstanz, Today, 04:44 AM
0 responses
9 views
0 likes
Last Post Hanstanz  
Started by juniortut, Today, 04:38 AM
0 responses
5 views
0 likes
Last Post juniortut  
Started by rojiinko, Today, 03:58 AM
0 responses
5 views
0 likes
Last Post rojiinko  
Started by mreanuzlazx, Today, 01:30 AM
0 responses
4 views
0 likes
Last Post mreanuzlazx  
Started by xinepev, Today, 12:33 AM
0 responses
5 views
0 likes
Last Post xinepev
by xinepev
 
Working...
X