Bob
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Here's a script to convert indicators and strategies
Collapse
X
-
Hi bobc635,
I have tried it with Visual Studio 5 with Nuget 3.5 attached, but it has not worked for me. I think this is partly because I am not sure exactly how to use the file provided with VS5. Maybe someone here can give some advice.
I have managed to update one of my simpler NT7 indicators to NT8 manually though. I just copied the .cs file to the NT8 indicator folders, compiled it, then I went through all the errors and corrected as necessary. I am working on a more complex indicator manually too, but that has taken several hours so far, and I'm still not finished. The beauty of NT8 is that you can right click on an indicator and select for it not to be included when you compile, so unlike NT7, NT8 can still work when you have indicators in the folder that have not yet compiled. Below are the steps I took:
My conversion method: Used to convert VolSMA 30/10/2016
i. Copy .cs file to NT8 indicator file
ii. Open NT8 Ninjascript Editor and open the file
iii. I had to add "System.Drawing.dll" from Microsoft.Net folder (C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319) to the Reference section of NT8 indicators: This is done once for each dll you add, and enables you to use Microsoft.Net codes. To add it you: open the editor and any indicator > right click > References > Add (then navigate to the folder and select the file).
iv. Using Declarations - some of them are different, and there are additional ones. Replace with the ones from the NT8 system VolMA Indicator as the main defaults, but can also check other system indicators that are similar to the one I am converting.
v. Change namespace to: namespace NinjaTrader.NinjaScript.Indicators
vi. Variables: Cannot see this section in locked NT8 indicators.
1) private DataSeries myDataSeries; Change to private Series<double> myDataSeries; (In MyBuySell05)
vii. Initialize(), OnStartUp(), OnTermination() - change to OnStateChange() - for more functionality
1) CalculateOnBarClose changed to: Calculate = Calculate.OnBarClose, Calculate = Calculate.OnEachTick and introduced a new Calculate = Calculate.OnPriceChange
2) Overlay changed to IsOverlay.
viii. OnBarUpdate()
1) .Set method no longer used - see manual.
2) VolSMA indicator changed as follows: // Set the calculated value to the plot: Plot0.Set(average); changed to: Value[0] = average;
ix. Region Properties: Some adjustments needed there.
1) DataSeries is now: Series<> e,g, public Series<double> Plot0 (See VolSMA)
2) [Description("Number of periods")] [GridCategory("Parameters")] & the {get set} code - these are replaced by: [Display(ResourceType = typeof(Custom.Resource), Name = "Number of periods", GroupName = "NinjaScriptParameters", Order = 0)] {get; set;}
Comment
-
Thanks a lot GeorgeW..... I was hoping to get most of the work done with the script, but I think you are right... I have quite a few custom indies that I built and it will be a lot of hours I am sure.... After the first few, it should go a lot quicker....
Thanks a lot!!!! Maybe someone will find the solution.
Bob
Comment
-
I too was having problems with the NuGet dependencies. When opening the script LINQPad was attempting to download the libraries and failing
It seems LINQPad actually bundles the dependancies when it is installed.
When the script is open, click F4 > Additional References > Browse
Browse to 'C:\Program Files (x86)\LINQPad5\ngen001' and select the NuGet dll files
I believe it also prompted me to add several .NET references
Comment
-
Thanks Sewards.... I did the browse and included the said files. I still cannot get the proper NuGet and still have the same errors, I guess that I am dumber than a rock..... I will keep trying for a while while I am working on the manual edits..... Argh.... I wish NT would make a converter and really support it... I appreciate all of the helpers in the forum....
Bob
Comment
-
Originally posted by GeorgeW View PostI'm in the same situation as you bobc635 - I have Net framework 4.6, but Linqpad is showing the Microsoft CodeAnalysis problem. There is a thread on the linqpad forum that refers to it as a known problem. I have tried their workaround at the bottom of the thread, but it doesn't work for me, maybe it will work for you.
Hope this helps you and bobc635,
I've spent a couple hours and finally figured out how to fix the same issues you were having, but I had to go a rounadabout way to get there. Here are the steps that worked for me:
1. Download the nuget 3.4.4 CLI here - https://dist.nuget.org/win-x86-comma...test/nuget.exe
2. Assuming you've already installed linqpad - move the nuget.exe file to linqpad's default folder for storing packages - C:\users\<user name>\AppDAta\Local\LINQPAD\NuGET.FW46
3. go to the windows command prompt
4. navigate to where the nuget.exe file is and update it (nuget.exe update -self). Leave the command window open, you will be using it again soon.
5. Open Linqpad and load the NT7toNT8.linq and try to run it.
I eventually had to fix four errors, but the ones you end up having to fix may be different from mine. The one we have in common is CodeAnalysis, what we will do is download that from the nuget site and point the reference in the program to it.
6. Assuming you get the CodeAnalysis (or CSharp) error, hit F4. Remove the reference that has the location asking you to download it.
7. In your command window, type nuget install Microsoft.CodeAnalysis -Version 1.3.2 followed by nuget install Microsoft.CodeAnalysis.CSharp -Version 1.3.2.
8. When they are done running, go back to linqpad. In the reference window, choose Add, followed by Browse. Navigate to the nuget.exe directory and you should see a lot of new folders. Choose the dll reference from CSharp.1.3.2\lib\net45 and also add the CodeAnalysis reference from Common.1.3.2\lib\net45
Even after those I had two further errors and I had to add the Systems.Collections.Immutable.dll from Immutable.1.2.0\lib\portable-net45 and System.Linq.dll from the 4.1.0\lib\net463
Each time you get an error you will have to figure out what dll it is referencing. Put the exception name in google and within a few links you should find it. Navigate through your directory try and find a folder that has that reference (or is its parent), and you should be able to figure it out. I you don't have it go to the nuget download site and find the name of the package to download and the latest stable version here:
I know full well I hacked my way through and this is probably not the best way to get it done, but like i said, it worked for me. YMMV.
Comment
-
Thanks for that detailed explanation Sobertrading partner.
At step 7, after pointing to the folder containing the download, I just typed into the command window "nuget install Microsoft.CodeAnalysis -Version 1.3.2", and that installed the CodeAnalysis and CodeAnalysis.CSharp folders as well as several others. In Windows 7, they are installed in folders directly under the user name.
For step 8, I used the dll files found within the net45 folders found in the parent folders Microsoft.CodeAnalysis.Common.1.3.2 and Microsoft.CodeAnalysis.CSharp.1.3.2
To Add them to linqpad, I went to: Query > References & Properties > Add > Browse (I then browsed to the folders indicated above and opened the following files: Microsoft.CodeAnalysis.dll Microsoft.CodeAnalysis.CSharp.dll). Once they were added to the Linqpad window, I pressed "Set as default for new queries" so they are now listed on the "Additional Namespace Imports" when I open linqpad. But still, when I open the NT7 to NT8 file, I still get the message that Microsoft.CodeAnalysis.CSharp needs to be downloaded. Any ideas how to resolve this?
Comment
-
Originally posted by GeorgeW View PostThanks for that detailed explanation Sobertrading partner.
At step 7, after pointing to the folder containing the download, I just typed into the command window "nuget install Microsoft.CodeAnalysis -Version 1.3.2", and that installed the CodeAnalysis and CodeAnalysis.CSharp folders as well as several others. In Windows 7, they are installed in folders directly under the user name.
For step 8, I used the dll files found within the net45 folders found in the parent folders Microsoft.CodeAnalysis.Common.1.3.2 and Microsoft.CodeAnalysis.CSharp.1.3.2
To Add them to linqpad, I went to: Query > References & Properties > Add > Browse (I then browsed to the folders indicated above and opened the following files: Microsoft.CodeAnalysis.dll Microsoft.CodeAnalysis.CSharp.dll). Once they were added to the Linqpad window, I pressed "Set as default for new queries" so they are now listed on the "Additional Namespace Imports" when I open linqpad. But still, when I open the NT7 to NT8 file, I still get the message that Microsoft.CodeAnalysis.CSharp needs to be downloaded. Any ideas how to resolve this?
Microsoft.CodeAnalysis
Microsoft.CodeAnalysis.CSharp
Microsoft.CodeAnalysis.Syntax
My Additional References have
Microsoft.CodeAnalysis.CSharp.dll
Microsoft.CodeAnalysis
Systems.Collections.Immutable.dll
System.Linq.dll
I can't be absolutely sure why it's still not working for you without seeing the actual error. I should mention I'm running on Win 7, which is why I didn't use the dll under the "portable-net45+win8" folders. I also downloaded and installed the Microsoft.CodeAnalysis.CSharp separately, though I know the main Microsoft.CodeAnalysis contains it. In the install process if it finds the same file it ignores it, so there's no harm.
Comment
-
I'm also running Win7.
Additional References: I add the same files you do to this section, but they do not remain there. When I open the NT7 to NT8 file, they disappear and a link to download Micorsoft.CodeAnalysis.CSharp appears.
Addition Namespace Imports: I have
Microsoft.CodeAnalysis
Microsoft.CodeAnalysis.CSharp
Microsoft.CodeAnalysis.CSharp.Syntax
The error I am getting is:
This query requires the following NuGet packages:
Microsoft.CodeAnalysis.CSharp
Download?
Comment
-
Originally posted by GeorgeW View PostI'm also running Win7.
Additional References: I add the same files you do to this section, but they do not remain there. When I open the NT7 to NT8 file, they disappear and a link to download Micorsoft.CodeAnalysis.CSharp appears.
Addition Namespace Imports: I have
Microsoft.CodeAnalysis
Microsoft.CodeAnalysis.CSharp
Microsoft.CodeAnalysis.CSharp.Syntax
The error I am getting is:
This query requires the following NuGet packages:
Microsoft.CodeAnalysis.CSharp
Download?
Comment
-
I've checked the path in NuGet package manager and it is the correct one. I'll try to download the NT7 to NT8 file again later and try it with a new file, as I have a feeling the old file may have picked up and retained the old settings, so it is always searching to download the codeAnalysis and Csharp files.
Thanks for your help, sobertradingpartner,
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Padan, Today, 02:02 AM
|
1 response
8 views
0 likes
|
Last Post Today, 07:56 AM | ||
Started by Mestor, Today, 03:15 AM
|
1 response
8 views
0 likes
|
Last Post Today, 07:41 AM | ||
Started by RaygunWizzle, Yesterday, 08:52 PM
|
1 response
9 views
0 likes
|
Last Post Today, 07:40 AM | ||
Started by Mestor, 03-10-2023, 01:50 AM
|
13 responses
314 views
0 likes
|
Last Post Today, 07:29 AM | ||
Started by Lele2k24, Yesterday, 11:24 AM
|
7 responses
25 views
0 likes
|
Last Post Today, 07:25 AM |
Comment