The start of the script looks as follows:
bool testing = false; // "true" to convert test scripts when making changes. bool convertIndicators = true; // "true" to convert indicators. bool convertStrategies = true; // "true" to convert strategies. string indicatorSourceFolder = @"C:\Users\UserName\Documents\NinjaTrader 7\bin\Custom\Indicator"; string indicatorDestinationFolder = @"C:\Users\UserName\Documents\NinjaTrader 8\bin\Custom\Indicators"; string indicatorFilesToConvert = "*.cs"; string strategySourceFolder = @"C:\Users\UserName\Documents\NinjaTrader 7\bin\Custom\Strategy"; string strategyDestinationFolder = @"C:\Users\UserName\Documents\NinjaTrader 8\bin\Custom\Strategies"; string strategyFilesToConvert = "*.cs";
- Backup your NT7 indicators and scripts in case you enter the wrong folders below.
- Download LINQPad 5 at www.linqpad.net. It's a free C# (and VB, F#, SQL) script runner - if you don't need intellisense. The script is a text file with full source (using .Net 4.6). If you don't want to use LINQPad, you can put the code in a console application (or WPF or whatever) instead - it needs the Microsoft code analysis Nuget package.
- Download the attached script, remove the ".txt" extension, open in LINQPad and make the following changes:
- Change the indicatorSourceFolder variable to match where you have your NT7 indicators
- Change the indicatorDestinationFolder variable to match where you have your NT8 indicators.
- Change the strategySourceFolder variable to match where you have your NT7 strategies
- Change the strategyDestinationFolder variable to match where you have your NT8 strategies.
- Click the green right arrow button to run (or press F5).
Notes on conversion:
- UserDefinedMethods.cs will need manual updating. If you don't have any changes to it that you need, you can just delete the NT8 converted version. If you have made changes to it that you need, you'll need to manually move the NT8 converted version into the AddOns folder and make the appropriate changes as stated in the NT8 documentation.
- The script uses only syntactic analysis - no semantic analysis is done so there are a few things it won't be able to convert and others it may get wrong. It worked for all the stock indicators (with the exceptions listed below) so I didn't feel the need to go through the extra hassle.
- Statements such as "Plots[0].Pen.DashStyle = DashStyle.Dash;" will convert to "Plots[0].Pen.DashStyle = DashStyleHelper.Dash;". This is one of the cases that would need semantic analysis to fix. Simply remove the "Helper" text.
- Some functions have changed signatures that will require simple manual fixing after conversion. Mostly the Draw* functions (16 overloads have changed - the rest are fine) are affected. Look at the sample indicator text at the bottom of the script to get an idea of what changes are needed.
- If the indicator overrides Plot, it will most likely require manual changes. There is no conversion to the DX API. This means classes such as StringFormat and SolidBrush won't convert since they are normally used for painting and the API is significantly different.
- The indicator/strategy must be the first or only class in the file.
- If something doesn't convert that you believe should have, there is a list of lookups below the initial setup portion of the script. You can try adding the appropriate lookup values.
Notes on making script changes:
If you want to make modifications to the script, you should probably set the "testing" variable to true. This will cause the indicators and strategies to be ignored and instead convert the sample indicator and strategy that are in string variables at the bottom of the script. These samples will allow you to quickly know if your changes have broken anything else. You can modify these samples to include code that allows testing the changes you are making. The output will go into the appropriate NT8 folder so you will need to remove these once you are done. The files will be named "ConversionSample.cs" for both indicator and strategy.
This was quickly put together to convert my code. I then went back and added the rest of the changes listed in the documentation. If you run into any bugs, feel free to make changes or post here and I will fix it if I have time. If you've made changes, it will probably be a good idea to post here so others may benefit.
Comment