Visual Studio Debugging

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Editor >

Visual Studio Debugging

Previous page Return to chapter overview Next page

You can debug your NinjaScript objects using Microsoft Visual Studio 2015, other version may work as well with potential limitations. NinjaScript objects are compiled into a single DLL, named "NinjaTrader.Custom.dll." When debugging, a special debug DLL is created for temporary use, with the same name as the release version.

 

Note: Using the debug DLL can incur a runtime performance impact, so it is recommended to disable Visual Studio debugging and re-compile your scripts when finished. This will replace the debug DLL with the release version.

 

Using Visual Studio Debugging

1. In the NinjaScript Editor, enable "Debug Mode" via the right-click menu, as seen in the image below. After this, compile your scripts to create the debug DLL.

 

NS_Editor_5

 

2. From the NinjaScript Editor, click on the Visual Studio icon NS_Editor_6 from the tool bar, which will automatically load the NinjaTrader.Custom project with your installed version of Visual Studio.

 

3. In Visual Studio, select Debug, then select Attach to Process

 

NS_Editor_7

 

4. Select NinjaTrader from the list of processes, then select Attach. Be sure the "Attach to" field is set to "Automatic: Managed code" or "Managed code".

 

NS_Editor_8

 

4. Open the NinjaScript source file within Microsoft Visual Studio and set your break point(s)

 

NS_Editor_9

 

5. Run your NinjaScript object in NinjaTrader and it should stop at your break points and all the debugging tools and information should be available to inspect the current state of the code.