Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Namespace access

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

    Namespace access

    I want to be able to access entry/exit functions from within the NinjaTrader.Strategy namespace but not within the strategy, ie:
    namespace NinjaTrader.Strategy
    {
    class test{
    public void testing(){
    NinjaTrader.Strategy.Strategy.EnterLong();
    }
    }

    /// <summary>
    ///
    /// </summary>
    [Description("My Strategy")]
    public class Tra******et2 : Strategy
    {}

    In the above, I can write code that compiles just fine until I call "EnterLong()". Then it either doesn't find the method or else in the above case I get "An object reference is required for the non-static method..." This suggests that I need an object or a more fully qualified name. The intent of what I want to do is to allow sharing of code across strategies. I do this all the time, but only if I don't call a built-in function like "EnterLong()". Is there a way to solve this? - I think I answered part of my own question: if you could call "EnterLong()" from any strategy then it would not be tied to a particular account. So now I realize you need a particular strategies object. Can I pass into a method a particular strategies object in order to access its "EnterLong()"?

    #2
    I got it to compile with the following:
    namespace NinjaTrader.Strategy
    {
    class testClass{
    public void testing(Strategy strat){
    strat.EnterLong();
    }
    }

    /// <summary>
    ///
    /// </summary>
    [Description("My Strat")]
    public class Tra******et2 : Strategy
    {
    private testClass tester = new testClass();
    tester.testing( this );
    }

    I know this is advanced programming, but as an NT developer I need to know how to handle such constructs. Are there other ways developers handle this situation? How about with DLL's, how do developers handle calls to built-in NT functions outside of the Strategy namespace?

    Comment


      #3
      Hello,

      Sorry, NInjaTrader does not support this type of communication between strategies or even referencing other strategies. Therefor I'm unable to really offer information your looking for since its not supported unfortunately. Its just going to take some playing around like you have been doing to get it to work. This is more advanced then I can offer support for, you may want to outreach to the NinjaTrader community to see if anyone has had success with doing this and try that route for more information on this.
      BrettNinjaTrader Product Management

      Comment


        #4
        I understand, but I guess I don't fully get the distribution process for strategies you want protected. I have read the section in the manual on this:


        This area talks about once you have created a strategy assembly, but not how to create the assembly in the first place. Do you have an example where a simple moving average (or other) strategy is created as an assembly? There is just not great documentation for development purposes.

        Comment


          #5
          NT allows you export (File>Utilities>Export, and select Export compiled assembly....) any indicator or strategy as a dll. You can obfuscate it too using the CliSecure (inbuilt and free).

          Comment


            #6
            bukkan,
            Thanks for the help, I'll try that out. I thought CliSecure was an extra fee, great to hear it is not.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            669 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            378 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            111 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            575 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            580 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X