Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

#include/import ?

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

    #include/import ?

    Howdy,
    Starting to get more into the language (I'm from a C++/Java background). I wanted to know if there is a way I can use includes to move all of my standard utility functions into one easy to update class file rather than trying to remember to copy/paste it between each strategy whenever I find a bug or need to do an update.

    Pretty much what I want to do is:
    Code:
    //Strategy_Utils
    namespace NinjaTrader.Strategy {
      public class Strategy_Utils : Strategy {
        public double util_function() {
          <Standard calculations here>
        }
        protected override void OnBarUpdate() {
          <Do I need to call this?>
        }
      }
    }
    Code:
    //MyStrategy
    namespace NinjaTrader.Strategy {
      public class MyStrategy : Strategy {
        protected override void OnBarUpdate() {
          Strategy_Utils.onBarUpdate();
          double test=Strategy_Utils.util_function();
          EnterLongLimit(DefaultQUantity,test,"test-signal");
        }
      }
    }
    Last edited by DKATyler; 09-09-2012, 02:42 PM.

    #2
    DKA,

    You can use the UserDefinedMethods.cs file. Also note that all files compile into the same assembly so if a method is properly nested using OOP it will be accessible elsewhere.
    Adam P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    89 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    48 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    31 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    34 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    69 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X