Does anyone have a preferred method of re-using common code (or code snippets) in NinjaScript?
Back when I used to write real code, I could embed a file which the compiler would pull in and place inline before compiling, so I could re-use common sections without replicating the same lines in multiple places. I would love to be able to do that in NinjaTrader.
I have written separate namespaces, with custom classes, and saved/compiled the script in the Indicator directory. Then added "Using name;" with the others at the top of the Indicator script that used the class. However, since the namespace isn't built off the Indicator code, I haven't figured out how to use Print() or any of the NinjaScript functions.
Likewise, I can write a static class that can be used by any other without forcing an instantiation, but it has similar limitations.
I ran into the problem yesterday of not being able to use Print, I'm sure there's some global object for the output window we need to get our hands on, but I don't know what it is.
My solution was intrusive but if I really need to communicate an error condition, I found that calling System.Windows.Forms.MessageBox.Show works.
I have wondering about the resource consumption by instantiating (calling a constructor) a class simply to re-use common code. NT is not the most efficient compiler in the world and I wonder about excess memory consumption and performance impacts. Up til now, the only methods I moved to a separate class were those which could be static, so no instantiation (construction) is required to call them.
I know one person got around not having the NT Draw routines by overriding the chart plot routines and creating his own.
Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.
Need help? 1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first. 2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses. 3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make. 4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance. 5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers. 6) Help using the forum? Watch this video to learn general tips on using the site.
If you want to support our community, become an Elite Member.
Thanks Mike. I was actually looking at some Visual Studio links earlier -- it would be nice but I don't have Visual Studio and haven't quite figured out how much it costs, which version do I need, etc. One day I plan to get there.
So I started this thread hoping to encourage folks to share techniques that work with just NT. :-) For poor folk like me!
VS 2010 Pro has some of that functionality and costs between $0-$500 depending on your use. I'm on the road now but that will be the subject of the next update in my "NinjaTrader and VS2010 for Dummies" thread when I'm back.
Basically you can create and edit your own Code Snippets for custom methods, etc which saves typing. The IDE also knows your file-specific variables, etc and can auto-fill them for you as you type.