Remember you can build/compile away in Visual Studio but you need to compile in Ninja Trader itself before things will work properly. Using the good old Search function, I note other users have posted that if you compile one Strategy or Indicator, it recompiles all your NinjaScript objects, so a suggestion was to have a NinjaScript editor window open while you are working in VS, but make sure its NOT the script you are actually editing.
I've created a dummy Indicator called CompileMe which I can keep open and hit compile as I go along. On the Ninja Trader Support forum there was one user who said he wrote a macro to do the same thing. I don't know how to do that. I will at some point, and post it here.
A button in Visual Studio that does that (recompile Ninja natively) would be a cool thing, but while I'm learning, an open NinjaScript editor screen works just fine.
So far this week:
- Using VS as a better editor than the default editor. This is something I want to master in the near term.
- Using VS and Subversion (futures.io (formerly BMT)Codex) for managing a development project. This is something I want to master in the long term.
Just a very quick update. 10 days in and I haven't broken anything!
I am very, very happy using the Visual Studio editor instead of the default editor. Little things like the editor remembering my variable names makes things easier.
I have been managing the code for three of my strategies and one of my indicators via VS, and so far so good. I recommend everyone read the link from the Ninja Support Forum in the post just before this to understand how very unsupported compiling outside of the default editor is.
It appears editing/compiling indicators (as opposed to strategies) is where you could create some problems if you are not careful. Indicators have the Forbidden Zone at the bottom where it says "NinjaScript generated code. Neither change or remove" which looks like it is generated on each compile and only generates properly if the default editor is used. Out of my depth, but I'll take their word for it.
My last compile is therefore always the CompileMe indicator in a seperate window
One last though for now... its probably overkill to use Visual Studio just for editing NinjaScript. Personally I'm doing it for professional development reasons and need to get my head around VS as an IDE, and (eventualy!) Subversion as collaboration and source control platform.
There are some good coders here who use VS regularly so feel free to throw me and the community a bone any time .
Last edited by MXASJ; August 3rd, 2010 at 09:09 AM.
The following 2 users say Thank You to MXASJ for this post:
Interesting point. I agree that the Visual Studio Intellisense is just that bit richer in features, however, what kept me back from using Visual Studio to debug NinjaScript is the missing of the NinjaScript Intellisense, which comes in quite handy when trying to think of the parameters of some arcane indicator. Is there perhaps any way to import this 'NinjaScript Intellisense' in Visual Studio?
If you mean debugging in the real sense of the word as supported by Ninja and you add breakpoints, etc in Visual Studio I'm afraid I can't comment yet as I haven't tried that feature.
For basic coding however, if you have referenced the libraries as outlined above the whole of the Ninja Script universe seems to be at your disposal... both supported and unsupported.
Attached a screenshot that shows how Visual Studio offers to complete MarketPosition, as well as a screenshot of what it wants to do with a custom indicator, in this case ADXVMA. It knows how many overloads, etc and what they are called.
Or did I completely misunderstand your question?
Last edited by MXASJ; August 3rd, 2010 at 08:45 PM.
The following 2 users say Thank You to MXASJ for this post:
Thanks MXASJ and sam028 for your thorough responses. Yes, we're talking about the same thing. I guess I did something quite wrong (I'm also a dummy in this area) when connecting Visual Studio to NinjaTrader, because the IntelliSense (as shown in the images) didn't show up on me.
Before I reinstall the various software programs and try to find the source of this 'disappeared IntelliSense', is attaching Visual Studio to NinjaTrader quite handy or more of a 'advanced debug-tool'? I'm asking because I didn't test it thorough, because the IntelliSense was a deal-breaker for me.
I've uninstalled NinjaTrader and Visual Studio, then reinstalled NinjaTrader & Visual Studio, then followed the steps outlined by MXASJ on the first page of this thread to the letter, and it works! I still don't know exactly why it didn't work earlier, but I'm glad it works now. Thanks alot MXASJ and Sam028 for the encouragement and wisdom.
Btw, I received the following error popup and error log...
With this step:
It turns out that this error was generated by the "Productivity Power Tools" extension. Disabling this extension removed the error and made it possible to add the references. After adding the references this extension can be re-activated and, as far as I know, works then okay.
I came across this NinjaTrader Support Forum-topic and, according to the NinjaTrader guys, gets the code (besides compiled) also (partly) re-written by NinjaTrader (thus: using Visual Studio will 'break' NinjaScript indicators?). That seems a little bit odd to me. What is your take on this?
Last edited by Jura; August 5th, 2010 at 04:41 AM.
Reason: expanded post
I use VS only for debugging. I don't see any advantages in editing in it. Can someone give some examples?
Some times when I want to distribute my strategy in restricted form I obfuscate and compile it.
Also I write only strategies. Not indicators. There are too many already. The only problem I have is that I can't put a conditional break point. The correct statement should be that I can put it, but then it takes ages to get to it. What I need is to break on a specific bar/time. Anyone else has this problem? My solution is to add a debug time parameter and put a break when true.
@baruchs: I'm wondering the same thing regarding of it's "useful" or not. Honestly, I just got it up & running today, so I guess MXASJ & Sam028 are better suited to answer this.
------ Quicker & easier working with Visual Studio and NinjaTrader.
I find the steps to work with Visual Studio alongside NinjaTrader quite cumbersome and annoying, so I went looking for a way to 'automate' this. So, I experimented what with AutoHotKey (www.autohotkey.com), a light-weight custom short-cut program. Please note, I'm not an "AutoHotKey-expert", but I would like to share some scripts which I use to work quicker with Visual Studio. If you look at the AutoHotKey documentation you'll see that the possibilities are endless, so this is just a primer.
This is my AutoHotKey script:
#s (Windows button + s) activates this script. First, the Visual Studio window is saved, and then the 'CompileMe' indicator is compiled in the background. The sound (from NinjaTrader) after compiling let's me know that compiling went successful.
Windows key + Z saves the Visual Studio file I'm working on, compiles the CompileMe indicator in the background, and pop-ups the Strategy Analyzer to backtest the strategy.
This script (under Windows key + A) does the following:
Save current Visual Studio file,
Compile the CompileMe indicator in the background,
Popup the Strategy Analyzer window,
Wait 3 seconds to ensure that the strategy is compiled in NinjaTrader,
Popup Output Window & clear this from the output from previous backtests,
Run the backtest.
As you can see, AutoHotKey is a great (& free ) way to automate frequent tasks.