Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can a strategy or indicator have more than a single source file?

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

    Can a strategy or indicator have more than a single source file?

    Sorry, probably this question is already answered but I could found it through the search.

    Is it possible to have multiple sources for a strategy/indicator?

    Thank you.

    #2
    Hi Alex, what would you mean please by mutiple sources? Do you mean data series / instruments?

    Comment


      #3
      Hi Bertrand,

      No, I mean multiple cs files. For instance, to use partial class definition or even different classes, because sometimes strategies get quite big for a single source file.

      Comment


        #4
        I see, strategies could not call other strategies, but you could call for example methods from UserDefinedMethods.cs or other indicators of course.

        Comment


          #5
          Can I use partial class definition for an indicator/strategy? Can I use a non-indicator class from within a separate cs file?

          I mean, there must be ways to split the code of an indicator/strategy into several files.

          Comment


            #6
            Originally posted by alex.nt View Post
            Can I use partial class definition for an indicator/strategy? Can I use a non-indicator class from within a separate cs file?

            I mean, there must be ways to split the code of an indicator/strategy into several files.
            ninjascript is all C#. just create your custom namespace and do whatever you like. Strategies/Indicators are partial class by itself (see UerDefinedMethod.cs file).

            Comment


              #7
              yes you can use multiple C# files and partial classes.

              Only limitation are Indicator derived classes. For these Ninja generates a custom script a the bottom of the file. Having 2 source code files for the same indicator derived class will probably mess that mechanism up. But try it, as you will see errors at compile time.

              Andreas

              Discover top crypto trading apps like Binance for secure, low-fee trading. Access crypto, forex, and more with real-time tools. Avoid scams, start small, and grow profits.

              Comment


                #8
                I guess a little example would be helpful. I will try to split the code into different cs-files and hopefullt report the results here.

                Comment


                  #9
                  Did this ever get resolved? Seems like a pretty straightforward request/need. Not sure I have ever written a C# program in just one source file. Multiple source files for a single indicator in NinjaScript may not be possible, as I sure don't see a File/New option anywhere. Am I missing something?

                  Comment


                    #10
                    For full disclosure, I am using the demo version. The features this thread addresses may be available in the paid version. It would be nice to know if this is the case.

                    Comment


                      #11
                      Originally posted by bernie_c View Post
                      Did this ever get resolved? Seems like a pretty straightforward request/need. Not sure I have ever written a C# program in just one source file. Multiple source files for a single indicator in NinjaScript may not be possible, as I sure don't see a File/New option anywhere. Am I missing something?
                      When you write a NinjaScript class, you are writing an object to be used by the NinjaTrader program: you are not writing a program.

                      I do not know of any language which allows you to write a single class in multiple files, unless you use partial classes. Ninjascript does allow that.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      580 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      335 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      102 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      554 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      552 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X