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

How to create new classes in separate files?

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

    How to create new classes in separate files?

    Apologies if this has been answered a million times before, but I have tried searching through this forum and the help guide and cannot find the info I need.

    I want to create separate files for each of the classes I build within my NT strategy.

    Is there any guidance on how to do this?

    Infact, what be really good is if I can just build the whole project using Visual Studio and bypass the NT script editor altogether. Is this possible?

    #2
    OK. I have been pointed by someone in a chatroom to the UserDefinedMethods file which contains a partial class which is compiled into the Strategy class, which is then used as the base for any custom strategies.

    I understand the NT architecture now.

    I have no wish to criticise NT's architecture as being a professional developer myself I understand the manner in which a product evolves over time. However, this architecture in very limiting for any serious developers wishing to use the NT platform to build a complex algo strategy. I understand that clients such as myself are not NT's target audience and the majority of NT's customer base aren't professional programmers. I can appreciate that there just aren't enough of us to make it cost effective to accommodate all our wishes.

    Can someone from NT please tell me if the architecture for building strategies will be any different in v7.0?

    Many thanks

    Comment


      #3
      Scooby,

      Reference this post. It explains the "partial class" and what it means to NT.
      mrlogik
      NinjaTrader Ecosystem Vendor - Purelogik Trading

      Comment


        #4
        Thanks Logik

        You have to admit though that doing that is a horrible cludge. Goes against every software design best practice I have used over the years.

        As you can tell, I'm new to the world of quant platforms and whilst I love the value for money and discretionary trading functionality offered by NT, as a platform on which to build a complex algo strategy...I'm starting to get the impression it just doesn't cut the mustard. I'm not criticising the guys at NT as they aren't building a product to compete in that marketplace.

        Do you have any ideas what other .NET products I could look at. The obvious other one is OpenQuant but I have heard that the support is dreadful. The QuantHouse product looks excellent, but it's enterprise level stuff and I don't want to even think how much they are charging for it.
        Last edited by ScoobyStoo; 05-12-2009, 05:43 AM.

        Comment


          #5
          You can use Visual Studio to debug NinjaScript. Unfortunately we cannot offer much support for this, but this is to the extent of the information we can provide: http://www.ninjatrader-support.com/H...ualStudio.html
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Scooby,

            Like any other platform / computer language, you just have to get use to the specific functional method, and syntax.

            To be honest with you, I have been through a few different platforms / companies and have not found another company with a strong customer service to platform ratio. I have brought bugs to the attention of NT developers and spoken with the president and vice president directly on matters. Where else do you have such a relationship with the company?

            In terms of partial classes, that is a C# / .NET design. This is different from what I have done in the past with Java, C, C++, and others, but once learned, the benefit is great. This is true especially as a developer that may have a few engineers working on a common set of code, or a developer that wants to deploy plug-ins, etc. Overall, I think once you get accustomed to this software design you will enjoy the benefits as well.

            I recommend staying with NT and working through everything until you get a very firm grasp of how everything works in .NET, C#, and NT's method of strategy / broker execution. It really is great.

            I hope this helps.
            mrlogik
            NinjaTrader Ecosystem Vendor - Purelogik Trading

            Comment


              #7
              Yep, I understand what you're saying Logik.

              I'm a professional C# developer and use partial classes day-in day-out, so I can see why they have been employed in this way. It just makes developing a complex quant strategy rather messy and tricky to manage.

              I have another thread going on at the moment over at http://www.ninjatrader-support2.com/...3953#post93953 discussing the merits of NT.

              I'm looking forward to the release details for NT v7.0. I really don't know what NT is trying to be...seems from v6.5 that it's a product for discretionary traders (a job it does excellently) with some support for automated quant strategies tacked on as an afterthought.

              I guess as an experienced pro developer I have pretty unrealistic expectations from NT.

              Comment


                #8
                Hey Scooby,

                I am not discretionary trader, which I agree, NT is really really great for.

                I am currently 100% automated. I read over your post about running into a show stopper (its great how I have heard that term with my customers :-) ). If you want to discuss anything with me (in terms of functionality, execution, the biolerplate operations) please, feel free to PM me about things. I may be able to clear some things up for you.

                In the event that you do run into a problem, there is always a solution; I have found ways around things in the past with other platforms.
                mrlogik
                NinjaTrader Ecosystem Vendor - Purelogik Trading

                Comment


                  #9
                  Much appreciated Logik.

                  If I decide to go with NT then no doubt I will take you up on your kind offer.

                  Comment


                    #10
                    You can put your classes in seperate files, just make sure they are in one of the NT namespaces (ie indicator or strategy namespace).

                    You can develop in visual studio also (thank heavens, I am lost without resharper), but you must compile in the NT script editor before you can use the indicator/strategy/whatever.

                    IMHO there are definitely some 'questionable' design decisions surrounding the use of statics and singletons in NT but I have tried pretty much every other platform and none of the others comes close to NT as far as strategy development is concerned.

                    Make sure you read the manual concerning the use of custom events if you plan to use them. I did a lot of head scratching over that one before I did what I should have done in the first place RTFM

                    Comment


                      #11
                      Originally posted by sefstrat View Post
                      You can put your classes in seperate files, just make sure they are in one of the NT namespaces (ie indicator or strategy namespace).

                      You can develop in visual studio also (thank heavens, I am lost without resharper), but you must compile in the NT script editor before you can use the indicator/strategy/whatever.

                      IMHO there are definitely some 'questionable' design decisions surrounding the use of statics and singletons in NT but I have tried pretty much every other platform and none of the others comes close to NT as far as strategy development is concerned.

                      Make sure you read the manual concerning the use of custom events if you plan to use them. I did a lot of head scratching over that one before I did what I should have done in the first place RTFM
                      Well, I'm going to locate any functionality that doesn't rely on NT in separate library in standalone assemblies. This will make my strategy that much more portable should I decide to shift platforms in the future. Obviously some stuff has to sit within the NT namespace though in order to function properly.

                      I'm happy using NT to compile as I know it runs a few additional processes before doing the compilation. There's no way though I can work with just a custom strategy class and access to the base strategy class via the UserDefinedMethods file. The result would be an unmaintainable mess of gargantuan proportions.

                      I (and many others probably) would be extremely grateful if you could provide some guidance on (i) developing NT strategies using Visual Studio and (ii) adding new objects to the NT namespace using separate files.

                      I asked a question on these forums about modifying the NinjaTrader.exe.config file (I want to use some of the Application Blocks from the MS Enterprise Library and they use the <application>.exe.config file to store some root config settings) and was bluntly told by an NT mod that this wasn't supported. This gave me the impression that NT aren't interested in helping developers push the product's capabilities (which is fair enough given their limited support resources). I'm glad to have found a few fellow pro coders on this site who have trodden the same path and are prepared to share their experiences and knowledge.

                      Thanks guys...

                      Comment


                        #12
                        Enterprise library?

                        What would you possibly need that kind of bloatware for in a strategy? I think you are way overcomplicating things.

                        You can do anything you want in a custom assembly though as long as you reference NT dll.

                        (sorry not trying to be rude but I was forced to use enterprise library on a project once and I have an intense hatred for it, xml hell )
                        Last edited by sefstrat; 05-13-2009, 09:16 AM.

                        Comment


                          #13
                          Yes indeed, it does suffer from a certain degree of bloating, but I am an inherently lazy coder and want to use a couple of the blocks for some end-of-day data dumping. Don't worry, I wouldn't dream of using anything developed by the good folk over at Accenture for anything critical.

                          OK, so I've been playing around and sussed out that I can add new class files to the directory C:\Documents and Settings\ScoobyStoo\My Documents\NinjaTrader 6.5\bin\Custom\Strategy and they will be automatically picked up for compilation as long as they are contained within the NinjaTrader.Strategy namespace. Hmmm, this opens up some possibilities.

                          You are right, this might not be so hard after all to squeeze into a VS solution.

                          Here's hoping...

                          Comment


                            #14
                            Instead of using the UserDefinedMethods.cs to extend the Strategy class

                            I opted for having my classes having a constructor parameter "strategy s"

                            I have a class for Trailing, a class for XmlHandling , etc. and these are al seperate files.

                            I am happy with it.

                            Hopefully NT 7 will use Net 3.5 which has a more advanced compiler and allows for extensions, etc.

                            But for the time beeing NT 6.5 allows me to do what I need, but I am a discretionary trader that needs only to apply certain exit strategies.

                            best regards




                            Namespace NinjaTrader.Strategy {

                            MyClass {
                            strategy s;
                            public MyClass(strategy S) {
                            s=S;
                            }
                            }

                            Comment


                              #15
                              This is what I chose as well.

                              It feels cleaner.



                              Originally posted by zweistein View Post
                              Instead of using the UserDefinedMethods.cs to extend the Strategy class

                              I opted for having my classes having a constructor parameter "strategy s"

                              I have a class for Trailing, a class for XmlHandling , etc. and these are al seperate files.

                              I am happy with it.

                              Hopefully NT 7 will use Net 3.5 which has a more advanced compiler and allows for extensions, etc.

                              But for the time beeing NT 6.5 allows me to do what I need, but I am a discretionary trader that needs only to apply certain exit strategies.

                              best regards




                              Namespace NinjaTrader.Strategy {

                              MyClass {
                              strategy s;
                              public MyClass(strategy S) {
                              s=S;
                              }
                              }

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by AttiM, 02-14-2024, 05:20 PM
                              12 responses
                              211 views
                              0 likes
                              Last Post DrakeiJosh  
                              Started by cre8able, 02-11-2023, 05:43 PM
                              3 responses
                              236 views
                              0 likes
                              Last Post rhubear
                              by rhubear
                               
                              Started by frslvr, 04-11-2024, 07:26 AM
                              8 responses
                              114 views
                              1 like
                              Last Post NinjaTrader_BrandonH  
                              Started by stafe, 04-15-2024, 08:34 PM
                              10 responses
                              47 views
                              0 likes
                              Last Post stafe
                              by stafe
                               
                              Started by rocketman7, Today, 09:41 AM
                              3 responses
                              11 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X