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

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 jaybedreamin, Today, 05:56 PM
        0 responses
        7 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        4 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        12 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        13 views
        0 likes
        Last Post bltdavid  
        Working...
        X