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 kaywai, 09-01-2023, 08:44 PM
    5 responses
    601 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by xiinteractive, 04-09-2024, 08:08 AM
    6 responses
    22 views
    0 likes
    Last Post xiinteractive  
    Started by Pattontje, Yesterday, 02:10 PM
    2 responses
    17 views
    0 likes
    Last Post Pattontje  
    Started by flybuzz, 04-21-2024, 04:07 PM
    17 responses
    230 views
    0 likes
    Last Post TradingLoss  
    Started by agclub, 04-21-2024, 08:57 PM
    3 responses
    17 views
    0 likes
    Last Post TradingLoss  
    Working...
    X