Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Object-oriented design for complex NinjaTrader strategies
Some of the strategies I develop are starting to get really complicated and long. I'd like to start modularizing my strats into separate class files, but NT doesn't seem to like that very much, every .cs has to either be a strat or an indicator. I also created a BaseStrategy class, which inherits from Ninja's strategy class, then tried to have my strats inherit from my BaseStrategy for my specific strategy sub-classes but Ninja didn't like that either. So how does one implement good OOP in Ninjatrader without creating one giant .cs file every time? The only alternative I can think of is to create an assembly (.DLL) in Visual Studio with helper methods and other re-usable functionality that my strats might want to use, like sending email, working with SQL Server, money management algorithms, etc, then reference it in Ninja and add a using statement to the DLL to bring in the outside behavior.
Any thoughts?
Can you help answer these questions from other members on NexusFi?
I've not tried this, but you might try the .*.NinjaScript.Utility approach, you can place some code in the napespace within the .Utility (ie: shodson.NinjaScript.Utility.cs) and call them from multiple indicators or strategies.
Then just do an include reference:
At the top of your code where you want to call it.
if I understand correctly, the NinjaScript.Utility is special in this way and for this purpose. I tried to find some documentation on it just now but couldn't, so I am only citing from prior examples of code I've seen that use this approach. (Roonius and VitaminC come to mind).
Thanks for the link to the project. I haven't used visual studio in a long time but I'm going to download it and try to make a simple indicator with it.
I got a copy of visual studio but haven't installed it yet. I plan to give it a try. What I want to do is put some of my algorithms into a DLL and then make an interface for Ninjatrader, Tradestation, & other platforms.