Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Ninjascript conversion
Collapse
X
-
That is correct. Developers will need to convert their code as needed to work within the new NinjaScript framework. We have an extensive list of code-breaking changes available in the NinjaTrader 8 Help Guide that should prove useful in the conversion process, and there are a lot of helpful people here on the forum who are quickly mastering NinjaTrader 8's NinjaScript who may be able to help, as well.Dave I.NinjaTrader Product Management
-
Hello,
We do not have any conversion walkthrough videos available at the moment, although that is an interesting idea to explore. If you are getting stuck at any particular point in your conversion process, I'll be happy to point you in the right direction.Dave I.NinjaTrader Product Management
Comment
-
Glenn/Skann,
I have a fairly simple process that eases the conversion process for indicators and strategies. If you're interested, when I have some time, I can create and post the two or three needed files. No tool but you should be able to convert most indicators without any modifications (or maybe just namespace and other minor modifications) to them.
Wil
Comment
-
Originally posted by wbennettjr View PostGlenn/Skann,
I have a fairly simple process that eases the conversion process for indicators and strategies. If you're interested, when I have some time, I can create and post the two or three needed files. No tool but you should be able to convert most indicators without any modifications (or maybe just namespace and other minor modifications) to them.
Wil
That sounds interesting...Kindly provide the details....Last edited by skann29; 10-06-2015, 03:13 PM.
Comment
-
Originally posted by skann29 View PostHi NinjaTrader_Dave or Ninjatrader support,
Can you please share a sample video for converting the indicator from NT 7 to NT 8. One easy conversion and one complex conversion.
Also they are converting most nt7 indicators free of charge to n8 in the file sharing section.
Comment
-
I've created the files for Indicators - Strategies should simply be copying the Indicator code over. I'm getting ready to work on something else and don't have time to test right now.
Steps for setup (One time):
- Create a new NinjaScript Editor. Open a file and right click in the editor. Choose "References...". Click "add". Browse to the .Net assemblies folder (should be %windowsdir%\Microsoft.NET\Framework\v4.0.30319 or something similar). Select "System.Drawing" and click add. This will add in the System.Drawing.dll to the references for NinjaTrader.Custom.dll since that is what NT7 indicators use.
- Place the attached Indicator.cs file into the "AddOns" folder (should be in My Documents\NinjaTrader8\bin\Custom). NT will pop a dialog for you to confirm using this file. You'll need to accept or it won't work. This file basically adds back in all the NT7 properties and methods the ninjas stole.
- Place the remaining attached files in the "Indicators" folder (should be in My Documents\NinjaTrader8\bin\Custom). These add back some of the classes and methods the ninjas turned to dust.
That's it for setup!
Steps for conversion:
- Change the namespace in your indicator to "NinjaTrader.Ninjascript.Indicators".
- Change the base class of your indicator to "Indicator" (should be IndicatorBase from NT7). e.g. "public class MyIndicator : IndicatorBase" changes to "public class MyIndicator : Indicator".
- If you have any plot properties (ones that reference Values[]), unfortunately, you'll have to change those. It's simple though. Change for instance "public IDataSeries MyPlot" to "public Series<double> MyPlot".
- OnBarUpdate should be renamed to OnBarUpdateEachTickCore (feel free to change the name in Indicator.cs).
- This is the most painful step You'll need to change the attributes that specify the name, description and category of any custom property. I've added a regular expression below that you can use. Works really great if you have RegexBuddy. Put the regex in the search box, put the replacement string in the replacement box and copy and paste your properties into the Test tab and click Replace. Voila! Attributes converted!
That's it!
If any indicators fail to compile, it's most likely you have run into a property or method I didn't add in. Shouldn't be difficult to add it to the Indicator.cs file.
Notes:
- I don't do multi-timeframe or mult-instrument work so I haven't added any of that functionality in. Shouldn't be difficult to do though.
- I converted the drawing functions over using regular expressions. Some of the overloads (probably about four) didn't have matching signatures in NT8 and I just commented those out. If you need them, you'll have to decide how to handle it.
- You'll more than likely get compilation errors because of missing namespaces. Just add them in.
- This is not meant for long term use - just a way to get your indicators working until you have time to update them. You don't want to miss out on all the good fu the ninjas worked so tirelessly to provide
Regular expression for the attributes (You'll have to modify if your attributes aren't in the same order):
(?<pre>\s*)\[Gui.Design.DisplayName\((?<displayname>"[^"]+")\)\].*?\[Description\((?<description>"[^"]+")\)\].*?\[(?:Grid)?Category\((?<category>"[^"]+")\)\]
The replacement string is:
${pre}[NinjaScriptProperty] ${pre}[Display(${pre} Name = ${displayname},${pre} Description = ${description},${pre} GroupName = ${category},${pre} Order = 1)]
You can remove the [NinjaScriptProperty] attribute from properties you don't want included in the factory methods. The order will be 1 for all the properties so you'll need to change that if you want different ordering (this should give you what was in NT7).
What's included:
- Added back properties such as CalculateOnBarClose.
- Added back properties that were renamed such as Overlay.
- Added back properties and methods that deal with color.
- Added back methods such as Initialize.
- Added back the Add method for adding plots.
- Added back the drawing methods (These don't return anything so you'll have to either change this or update your indicator if you rely on the returned object).
- Added back series such as DataSeries.
- Added back the Set method on the series classes.
- I don't like having a bunch of code in one method so I split out the OnStateChanged into separate methods. You can change that back if you want.
- I work mostly with range bars so there's some range bar code in there. Feel free to remove.
If you run into any issues or if there is a lot of missing properties/methods, let me know. I had to remove some stuff and add in some stuff before posting so everything is not fully tested. Let me know if I missed any files or if it doesn't compile for you.
If you want the NT7 HeikenAshi indicator, I've uploaded it to thread http://ninjatrader.com/support/forum...ad.php?t=78846.Last edited by wbennettjr; 10-06-2015, 06:41 PM.
Comment
-
Originally posted by wbennettjr View PostI've created the files for Indicators - Strategies should simply be copying the Indicator code over. I'm getting ready to work on something else and don't have time to test right now.
Steps for setup (One time):
- Create a new NinjaScript Editor. Open a file and right click in the editor. Choose "References...". Click "add". Browse to the .Net assemblies folder (should be %windowsdir%\Microsoft.NET\Framework\v4.0.30319 or something similar). Select "System.Drawing" and click add. This will add in the System.Drawing.dll to the references for NinjaTrader.Custom.dll since that is what NT7 indicators use.
- Place the attached Indicator.cs file into the "AddOns" folder (should be in My Documents\NinjaTrader8\bin\Custom). NT will pop a dialog for you to confirm using this file. You'll need to accept or it won't work. This file basically adds back in all the NT7 properties and methods the ninjas stole.
- Place the remaining attached files in the "Indicators" folder (should be in My Documents\NinjaTrader8\bin\Custom). These add back some of the classes and methods the ninjas turned to dust.
That's it for setup!
Steps for conversion:
- Change the namespace in your indicator to "NinjaTrader.Ninjascript.Indicators".
- Change the base class of your indicator to "Indicator" (should be IndicatorBase from NT7). e.g. "public class MyIndicator : IndicatorBase" changes to "public class MyIndicator : Indicator".
- If you have any plot properties (ones that reference Values[]), unfortunately, you'll have to change those. It's simple though. Change for instance "public IDataSeries MyPlot" to "public Series<double> MyPlot".
- This is the most painful step You'll need to change the attributes that specify the name, description and category of any custom property. I've added a regular expression below that you can use. Works really great if you have RegexBuddy. Put the regex in the search box, put the replacement string in the replacement box and copy and paste your properties into the Test tab and click Replace. Voila! Attributes converted!
That's it!
If any indicators fail to compile, it's most likely you have run into a property or method I didn't add in. Shouldn't be difficult to add it to the Indicator.cs file.
Notes:
- I don't do multi-timeframe or mult-instrument work so I haven't added any of those functionality in. Shouldn't be difficult to do though.
- I converted the drawing functions over using regular expressions. Some of the overloads (probably about four) didn't have matching signatures in NT8 and I just commented those out. If you need them, you'll have to decide how to handle it.
- You'll more than likely get compilation errors because of missing namespaces. Just add them in.
- This is not meant for long term use - just a way to get your indicators working until you have time to update them. You don't want to miss out on all the good fu the ninjas worked so tirelessly to provide
Regular expression for the attributes (You'll have to modify if your attributes aren't in the same order):
(?<pre>\s*)\[Gui.Design.DisplayName\((?<displayname>"[^"]+")\)\].*?\[Description\((?<description>"[^"]+")\)\].*?\[(?:Grid)?Category\((?<category>"[^"]+")\)\]
The replacement string is:
${pre}[NinjaScriptProperty] ${pre}[Display(${pre} Name = ${displayname},${pre} Description = ${description},${pre} GroupName = ${category},${pre} Order = 1)]
You can remove the [NinjaScriptProperty] attribute from properties you don't want included in the factory methods. The order will be 1 for all the properties so you'll need to change that if you want different ordering (this should give you what was in NT7).
What's included:
- Added back properties such as CalculateOnBarClose.
- Added back properties that were renamed such as Overlay.
- Added back properties and methods that deal with color.
- Added back methods such as Initialize.
- Added back the Add method for adding plots.
- Added back the drawing methods (These don't return anything so you'll have to either change this or update your indicator if you rely on the returned object).
- Added back series such as DataSeries.
- Added back the Set method on the series classes.
- I don't like having a bunch of code in one method so I split out the OnStateChanged into separate methods. You can change that back if you want.
- I work mostly with range bars so there's some range bar code in there. Feel free to remove.
If you run into any issues or if there is a lot of missing properties/methods, let me know. I had to remove some stuff and add in some stuff before posting so everything is not fully tested. Let me know if I missed any files or if it doesn't compile for you.
If you want the NT7 HeikenAshi indicator, I've uploaded it to thread http://ninjatrader.com/support/forum...ad.php?t=78846.
Comment
-
One step I forgot in the conversion is that OnBarUpdate should be renamed to OnBarUpdateEachTickCore (feel free to change the name in Indicator.cs). This is the method that will be called with each Tick if Calculate is set to OnEachTick (CalculateOnBarClose = false) or called on the last tick if Calculate is set to OnBarClose (CalculateOnBarClose = true).
Comment
-
Originally posted by wbennettjr View PostOne step I forgot in the conversion is that OnBarUpdate should be renamed to OnBarUpdateEachTickCore (feel free to change the name in Indicator.cs). This is the method that will be called with each Tick if Calculate is set to OnEachTick (CalculateOnBarClose = false) or called on the last tick if Calculate is set to OnBarClose (CalculateOnBarClose = true).
I am getting the compilation error for Indicator.cs as attached in the snapshot. Kindly help me fix the issue. Please find the attached.
Comment
-
Ah! I forgot to remove that one. It's looking for an extra file that I use. I've attached it (goes in the Indicators folder). Alternatively, you can remove the "using NinjaTrader.NinjaScript.Indicators.WilInterfaces" line and change the equality comparisons (IsEqualTo, IsGreaterOrEqualTo, ... to ==, >=, etc...).Attached Files
Comment
-
-
Originally posted by wbennettjr View PostDid everything work for you now Skann?
Thanks again for following up and will keep you posted.
Comment
-
Originally posted by skann29 View PostI completed the one time setup over the weekend. I will take one NT7 indicator and will apply the changes you are saying and will update you. I can do this over the weekend, because of my work nature.
Thanks again for following up and will keep you posted.
Can you please break the Regex mapping to "one to one". When I try to do this "Put the regex in the search box, put the replacement string in the replacement box and copy and paste your properties into the Test tab and click Replace."
I get the error "The regular expression does not match the test subject"
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by zstheorist, Today, 07:52 PM
|
0 responses
7 views
0 likes
|
Last Post
by zstheorist
Today, 07:52 PM
|
||
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
150 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
6 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
6 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
Comment