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 Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,789 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    837 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,293 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    13 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    63 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X