Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

ML.NET project addition

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ML.NET project addition

    I have created a machine learning project in Visual Studio using ML.NET. The project uses the Microsoft.ML nuget package which has various other dependencies. I would like to get this into Ninjatrader for use in a trading strategy. Is it possible to add the required project to the Ninjatrader solution file and reference the necessary classes this way? Or is it preferable to decompose all the nuget packages into their source dll's and place these into the appropriate Ninjatrader directory?
    Attached Files

    #2
    Hello mballagan,

    Or is it preferable to decompose all the nuget packages into their source dll's and place these into the appropriate Ninjatrader directory?
    This would be what is suggested. The most simple way to try an external nuget library would be to:
    1. Create a new visual studio .net 4.8 desktop WPF application on your desktop
    2. Add the nuget package
    3. build the solution
    4. Open the Bin/debug folder and collect whatever dll's or resources are required
    5. Place those files in the Documents\NinjaTrader 8\bin\Custom folder
    6. Use the NinjaScript editor to add references and check if the platform can compile
    7. Try using the references in a script
    A lot of Microsoft's newer tutorials are targeted for dotnet which is not the same as .net desktop 4.8 so creating a VS solution that targets the same framework NinjaTrader targets is the best first step to ensure whatever you use can work in NinjaScript or was built for the correct framework.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I have carried out the steps as you have advised. I get the following compilation error. Any suggestions?
      The type 'System.Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

      Comment


        #4
        Hello mballagan,

        Is that from within NinjaTrader or visual studio?

        The reference to netstandard would not be able to be used, if the library is not designed to be used with .net framework directly and requires other items like netstandard or netcore it wont be able to be referenced.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          The error occurs within Ninjatrader. All is ok within Visual Studio. I think ML.NET does use .NET core somewhere under the hood.

          Comment


            #6
            Hello mballagan,

            Thank you for that detail. Yes it sounds like you completed the process correctly however if the reference utilizes any other frameworks outside of .net desktop 4.8 or lower that would be outside of the scope that we could help with getting referenced. You can try to search online what may be required to utilize that library or its underlying frameworks with .NET framework 4.8 desktop but I would not have any suggestions on that.

            If you make some kind of external application which utilizes the framework you can always look at other means of calling that and providing data. You could for example make use of a stream writer to write data out of the platform and use other C# means like calling an external process. These are more of general C# tasks so not necessarily something our support could directly help with. You can search online for C# means of writing data or communicating between C# applications for more ideas.

            I look forward to being of further assistance.

            JesseNinjaTrader Customer Service

            Comment


              #7
              Jesse, Thanks for your response. I have managed to get it working but had to create a Web API project that wrappers around the ML.NET model. This is then deployed to Azure (it can be hosted in local IIS but I had some trouble getting this going) and the necessary API to connect to the service created using Postman which generates the necessary C# code to connect. So its not exactly the original goal of a self contained block which could reside inside the Ninjtrader directories but it works.

              Comment


                #8
                Originally posted by mballagan View Post
                Jesse, Thanks for your response. I have managed to get it working but had to create a Web API project that wrappers around the ML.NET model. This is then deployed to Azure (it can be hosted in local IIS but I had some trouble getting this going) and the necessary API to connect to the service created using Postman which generates the necessary C# code to connect. So its not exactly the original goal of a self contained block which could reside inside the Ninjtrader directories but it works.
                Hey mballagan, I am having a similar issue. I have a crappy fix right now but it's extremely inefficient. Would love to share details with you if you interested in linking up.
                Last edited by NinjaTrader_Jesse; 02-11-2021, 12:18 PM. Reason: no emails on the forum please use Private messages

                Comment


                  #9
                  Can we have a tutorial on that mballagan? I am looking to implement something like that in my strategy but am unable to include ML.net in the project.

                  Comment


                    #10
                    Hi,

                    If you're interested, we developed a machine learning add-on for NinjaTrader that uses ML.Net. There's a free trial available to try it out.

                    Cheers,
                    Eric


                    Comment


                      #11
                      Has anyone compiled ML.NET from source using .net 4.8 framework for use in ninjatrader? I'd like to reference the DLL's.

                      Thanks,
                      eleven

                      Comment


                        #12
                        We didn't compile the source for AutoML.Net but did use nuget to get the compiled versions. You'll need to reference and register the dlls to use them.

                        Cheers,
                        Eric

                        Comment


                          #13
                          ericmacd Thanks for the idea. It worked great importing the DLL's.
                          Last edited by eleven; 01-10-2023, 12:30 AM.

                          Comment


                            #14
                            Thanks for all the input on this subject. I've been experimenting with ml.net's automl and not sure if I'm building the projects correctly for use with NT. Here are the steps I take:

                            1. Open Visual Studio 2022 and Create new Project
                            2. Choose Class Library (.NET Framework)
                            3. Configure with Project name (ClassLibrary) and Solution name (ClassLibrary), choose .NET Framework 4.8 from dropdown menu and Create
                            4. View>Solution Explorer. Right click on project and Add>Machine Learning Model, name the model (ClassLibrary).
                            5. For now I just train the model with an uploaded CSV file built from exported chart indicator data
                            6. Build the project (ClassLibrary)
                            7. Locate the ClassLibrary.dll, Microsoft.ML.dll, files in the bin/debug folder, copy and paste into NT8/bin/custom folder
                            8. Right click in Ninjascript Editor, References, add the path to the dll files.

                            At this point the type or namespaces for the referenced dlls in the indicator script don't exist. What am I missing?

                            Comment


                              #15
                              Hi Lance,

                              It's hard to tell exactly what you're missing without code but did you add references to the microsoft dlls in Visual Studio too?

                              Cheers,
                              Eric

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by love2code2trade, 04-17-2024, 01:45 PM
                              4 responses
                              31 views
                              0 likes
                              Last Post love2code2trade  
                              Started by cls71, Today, 04:45 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post eDanny
                              by eDanny
                               
                              Started by proptrade13, Today, 11:06 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post proptrade13  
                              Started by kulwinder73, Today, 10:31 AM
                              1 response
                              10 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by RookieTrader, Today, 09:37 AM
                              3 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X