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

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 Mindset, 05-06-2023, 09:03 PM
    9 responses
    258 views
    0 likes
    Last Post ender_wiggum  
    Started by Mizzouman1, Today, 07:35 AM
    4 responses
    18 views
    0 likes
    Last Post Mizzouman1  
    Started by philmg, Today, 01:17 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by cre8able, Today, 01:01 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by manitshah915, Today, 12:59 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Erick  
    Working...
    X