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)
AutoHotKey scripts for editing/debugging NT scripts in Visual Studio
If you debug ninjascripts in Visual Studio, you know what a pain the repetitive process of launching everything, recompiling the script and attaching VS to the NT process is.
I used AutoHotKey to automate some of this.
First script:
1. launches NT
2. connect to data provider
3. open Ninjascript in NT
4. launch VS
5. open Ninjascript in VS
6. compile script in NT
7. reload all scripts in VS
8. attach VS to NT process (I use the Attach to Anything extension in VS and created a little toolbar; would be nice to access this with a shortcut, but not sure how or if possible)
9. close NT editor
Script is pretty extensively commented, so hopefully it's easy to follow along. I'm pretty new to AHK, and used a lot of pauses and WinWait commands to prevent the script from outrunning itself. It works pretty well now, and I could probably go back and eliminate some of the pauses and WinWait's to make it a touch quicker. If you make any useful mods to this or have any suggestions, post 'em up.
If anyone has other useful AHK scripts they use to automate steps when working with VS and NT, or suggestions, feel free to add to this thread.
This next AHK script is intended to be used when making changes to your ninjascript while debugging. After saving changes in VS, run this script to stop debugging, open the script in NT editor, compile, reload in VS, attach VS to NT process and close NT editor.
A little more detail on Attach to Anything ("A2A") as some might find this useful, regardless of whether they are accessing it in a script or manually - either way, it's a lot quicker than Debug > Attach to Process > scroll down to find NT > Attach.
You can grab this extension by going to VS Extension Manager. Search Online Gallery for "Attach to Anything". In A2A's options (can access from either toolbar or Tools > Options > Debugging > A2A), select the the Ninjatrader process and Add. Now in the A2A toolbar, you will have Ninjatrader.exe.
It would be nice to access this by shortcut (in my AHK script, I access it by mouse pointer), but I'm not sure how, or if it's even possible. If anyone knows how to do this, please let me know, thanks.
FWIW, here is a snippet that works on my machine. Both VS2013 and NT7 are assumed to be open. You have installed the ReAttach extension, and you have used it to attach to the NT process. If you hover over the red play button, you'll see that Ctrl+R,Ctrl+1 re-attaches (that is the assumption in the script). Your NT debugging is set to Debug Mode.
Once you have run the script, F4 (from any window, not just VS or NT) will ReAttach to NT, open an indicator, compile it and close the window. Now you can Reload NinjaScript from a chart to hit breakpoints in VS.
Quote:
Originally Posted by NinjaTrader_Brett View Post
C# 6.0 came out near the tail end of our development and is actually a little tricky to integrate support for that since the compiler is no longer part of .net framework. You have to use the new roslyn compiler now separately. Furthermore various third party tools we use didn't support it yet so we made the decision to hold off on support for that.
There is a workaround which is developing in Visual Studio to compile a .dll and import it into NinjaTrader. I made this template visual studio file which allows you to do just that. As long as NT is installed in default location you can develop in this visual studio project. Press F5 and it will copy over a DLL to NT to autoload and start NinjaTrader in debug mode. The example uses an AddOn but you could do indicators/strategies/other as well.
-Brett
Brett,
My additional notes:
The NinjaTraderAddon project properties Build Steps has two xcopy commands under Build Steps to copy its dll and pdb files to the proper location, and the NinjaTraderStartupProject project properties Debug has "Start external program" to launch NT8.