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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    68 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    38 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X