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

Multiple classes within strategy

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

    #16
    Unfortunately we only support the inheritance model which in enforced by the strategy wizard. In addition I suggest to not use the strategy name "Trade" to avoid confusion.

    Anything outside that scope would be beyond what we are able to provide support for. It may or may not work. In any case you would need to try on your own.

    Comment


      #17
      Dierk,

      I want to personally thank you for this very informative reply. Particularly your closing line.

      A sincere thank you,




      Originally posted by NinjaTrader_Dierk View Post
      Unfortunately we only support the inheritance model which in enforced by the strategy wizard. In addition I suggest to not use the strategy name "Trade" to avoid confusion.

      Anything outside that scope would be beyond what we are able to provide support for. It may or may not work. In any case you would need to try on your own.

      Comment


        #18
        Sefstrat,

        I have been employing this technique to centralize code and I found that setting up a base class using this type of a template was very efficient.

        One thing to remember is that in classes that inherit from the base, you have to do the following in your constructor.


        public class MyClass : MyBaseClass
        {

        public MyClass(Strategy s) : base(s)
        {
        // put your initilizing code in here.
        }

        }

        Originally posted by sefstrat View Post
        Yeah Trade class should not inherit from strategy for what you are trying to do.

        Pass your strategy into Trade constructor if you need to access Strategy members.

        ie

        public class Trade
        {
        Strategy s;

        public Trade(Strategy strat) { s = strat; }

        .....
        }


        then inside your strategy:

        Trade t = new Trade(this);

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sofortune, Today, 11:45 PM
        0 responses
        3 views
        0 likes
        Last Post sofortune  
        Started by zzeric, Today, 11:23 PM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Pep de lou, Today, 08:14 PM
        2 responses
        20 views
        0 likes
        Last Post bltdavid  
        Started by fingers, 12-15-2023, 08:44 AM
        6 responses
        139 views
        0 likes
        Last Post bltdavid  
        Started by algospoke, 05-13-2024, 06:53 PM
        4 responses
        33 views
        0 likes
        Last Post algospoke  
        Working...
        X