Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Proper way to create a system library?

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

    Proper way to create a system library?

    I'm following the instructions for creating custom methods, but it seems that I need to create them as namespaces of Indicator or Strategy...

    How do I go about creating a generic function library within NT?

    Is this just a matter of declaring my own namespace, and calling it in my indicators/strategies? How would I export my own namespace from NT?

    Better way to create a toolkit library in NT? (either internal or external)

    #2
    I answered my own question...

    In the userdefinedmethod, I created my own namespace/class/methods ... saved as unique filename... and added the 'using' syntax for my namespace.

    Thanks

    Comment


      #3
      hi, I need to understand what I am doing wrong here... I want to create my own library of classes and methods.

      I saved UserDefinedMethods as "MFNTLibrary"

      #region Using declarations
      using .... all the defaults

      #endregion

      namespace MFNTLibrary
      {

      partialclass strategy
      {

      // my new method
      public void PrintStrDateTime(string callingFunc, string strval)
      {
      Print(callingFunc +
      ":" + strval + DateTime.Now.ToString());
      }
      }
      }

      Then in my Strategy, I call the library:

      using.... all the defaults....

      using MFNTLibrary; // added this
      #endregion

      namespace NinjaTrader.Strategy
      {

      public class FMDivergTFTLB : Strategy
      {
      privatestring funcName = "FMDivergTFTLB";
      protected override void Initialize()
      {
      CalculateOnBarClose =
      true;
      EntryHandling = EntryHandling.UniqueEntries;

      PrintStrDateTime(funcName,
      "Initializing.... ");


      When I try to compile this I get 2 errors:

      1) on the MFNTLibrary:
      "the print name doesn't exist in the current context"

      2) PrintStrDateTime doesn't exist in the current context

      Can you let me know what I am doing wrong please?

      Comment


        #4
        Originally posted by DaFish View Post
        hi, I need to understand what I am doing wrong here... I want to create my own library of classes and methods.

        I saved UserDefinedMethods as "MFNTLibrary"

        #region Using declarations
        using .... all the defaults

        #endregion

        namespace MFNTLibrary
        {

        partialclass strategy
        {

        // my new method
        public void PrintStrDateTime(string callingFunc, string strval)
        {
        Print(callingFunc +
        ":" + strval + DateTime.Now.ToString());
        }
        }
        }

        Then in my Strategy, I call the library:

        using.... all the defaults....

        using MFNTLibrary; // added this
        #endregion

        namespace NinjaTrader.Strategy
        {

        public class FMDivergTFTLB : Strategy
        {
        privatestring funcName = "FMDivergTFTLB";
        protected override void Initialize()
        {
        CalculateOnBarClose =
        true;
        EntryHandling = EntryHandling.UniqueEntries;

        PrintStrDateTime(funcName,
        "Initializing.... ");


        When I try to compile this I get 2 errors:

        1) on the MFNTLibrary:
        "the print name doesn't exist in the current context"

        2) PrintStrDateTime doesn't exist in the current context

        Can you let me know what I am doing wrong please?
        Your partial class is "strategy". Case sensitive: try "Strategy".

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        602 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        347 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        559 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        558 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X