• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling Strategy methods from another class

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

    Calling Strategy methods from another class

    Hello,

    I'm new to NinjaTrader and NinjaScript, but have some programming background in c#.
    As far as I can see all the methods are incapsulated into Strategy class
    I wonder if I can do something like:
    Code:
    public class MyStrategy : Strategy
    {
        protected override void Initialize()
        {
              Class1 c1 = new Class1(this);
              c1.DoSmth();
        }
    }
    
    public class Class1 
    {
        private readonly Strategy _strategy;
        public Class1(Strategy strategy)
        {
            _strategy = strategy;
        }
    
        public void DoSmth()
        {
              _strategy.EnterLong();
        }
    }

    #2
    Hello qwerty_2004,
    Welcome to the forum and I am happy to assist you.

    NinjaScript is essentially C# and you will be able to use any method/rules which are applied to C#.

    You can take reference to this member submitted code;
    http://www.ninjatrader.com/support/f...04&postcount=1


    However please do note, we offer support for documented NinjaScript codes only (as found in our help guide) and any advanced C# concepts is not officially supported by us.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thank you NinjaTrader_Joydeep for example code,
      But this is not exactly what i wanted to know.

      I want to figure out if NinjaScript API functions are declared as 'public' (so I can use them from external classes)

      Comment


        #4
        Hello qwerty_2004,
        NinjaScript strategies are public classes and you will be able to call them from external classes.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Thanks a million!
          Will carry on involving

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ntbone, Yesterday, 09:54 PM
          0 responses
          6 views
          0 likes
          Last Post ntbone
          by ntbone
           
          Started by rwilliam, Yesterday, 03:14 PM
          0 responses
          8 views
          0 likes
          Last Post rwilliam  
          Started by rwilliam, Yesterday, 03:10 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by rontronimous, Yesterday, 03:04 PM
          2 responses
          12 views
          0 likes
          Last Post rontronimous  
          Started by zacharydw00, Yesterday, 03:14 PM
          0 responses
          9 views
          0 likes
          Last Post zacharydw00  
          Working...
          X