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

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?
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        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

              Start trading with Exness, a leading platform offering low spreads, advanced tools & a wide range of assets. Open your account today!

              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 lorem, Today, 09:18 AM
                      1 response
                      4 views
                      0 likes
                      Last Post lorem
                      by lorem
                       
                      Started by bmartz, Today, 09:30 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post bmartz
                      by bmartz
                       
                      Started by GussJ, 03-04-2020, 03:11 PM
                      14 responses
                      3,244 views
                      0 likes
                      Last Post GussJ
                      by GussJ
                       
                      Started by ArkansasClint, Today, 09:28 AM
                      0 responses
                      0 views
                      0 likes
                      Last Post ArkansasClint  
                      Started by hazylizard, Today, 08:38 AM
                      4 responses
                      12 views
                      0 likes
                      Last Post hazylizard  
                      Working...
                      X