Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ML.NET project addition

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

    #16
    Hello Lance El Camino,

    it sounds like the project setup is fine and if it compiled and made an output it sounds like that part was successful. Make sure you have compiled in the NinjaScript editor after adding the references.

    The intelleprompt may not pick up your custom namespaces or types so you may need to just type out some test code in the editor and then compile to make sure it compiles or throws an error. If you are still having difficulty in generating a .dll from a external visual studio project I would suggest opening a new thread for that specifically instead of replying here. You can leave out that you are using ml.net in your custom project and just make a post that you had trouble with the process you mentioned. It would also be good to see some test code for what you are trying to export to get a better idea of how that should show up in the platform.

    Comment


      #17
      Thanks Jesse,

      I have no problem generating dlls from VS as per my previous post. For now I'm just adding the namespace as a Using Declaration to see if it compiles:

      Code:
      #region Using declarations
      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.ComponentModel.DataAnnotations;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows;
      using System.Windows.Input;
      using System.Windows.Media;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Gui;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Gui.SuperDom;
      using NinjaTrader.Gui.Tools;
      using NinjaTrader.Data;
      using NinjaTrader.NinjaScript;
      using NinjaTrader.Core.FloatingPoint;
      using NinjaTrader.NinjaScript.DrawingTools;
      
      #endregion
      
      using Microsoft.ML;​
      When I compile it produces the following error: The type or namespace name 'ML' does not exist int the namespace 'Microsoft' (are you missing an assembly reference?). I've followed all the steps from previous support posts: generated the dlls, placed them in the NT8\bin\Custom folder:

      Click image for larger version

Name:	image.png
Views:	713
Size:	99.7 KB
ID:	1230663

      And have made the reference in Ninjascript Editor:

      Click image for larger version

Name:	image.png
Views:	675
Size:	43.2 KB
ID:	1230664

      So why the CS0234 error?

      Comment


        #18
        Hello Lance El Camino,

        Unfortunately I wouldn't be able to say regarding the ML framework, that is not something I am familiar with. If you are making your own namespaces/classes in visual studio and exporting that to a dll that would be something our support could try to assist with. The ML framework is an external library so I couldn't really say why it may not be working. You can try checking the control center log to see if any loading errors are reported for that dll. If you are getting an error like post 3 of this thread then you can try manually adding a reference to the config for netstandard.dll.



        Comment


          #19
          Thanks Jesse. I totally understand support capacity in this regard. If it helps, I do see in the log that "Vendor assembly 'Microsoft.ML' version='1.0.0.1' loaded" as well as the class library dll. So I'm wondering if these are dependent on other dlls within the project. Here is what's in the Debug folder for the project:

          Click image for larger version

Name:	image.png
Views:	686
Size:	149.2 KB
ID:	1230705

          As you can see it's a lot of stuff! Hopefully someone can chime in on the exact way to get it done. Thanks!

          Comment


            #20
            Hello Lance El Camino,

            It likely is dependent on other frameworks, you need to match the references you see when using that in visual studio. The NinjaScript editor would need all the same requirements referenced and placed in the bin/custom folder.

            Comment


              #21
              Has anyone got "Microsoft.ML.LightGbm.dll" to load? I have many Microsoft.ML libraries loaded, however, I cannot load that one.

              Comment


                #22
                eleven
                I couldn't but it looks like it depends on the LightGBM package:

                Click image for larger version

Name:	image.png
Views:	669
Size:	150.3 KB
ID:	1231654
                I found the lib_lightgbm.dll in the packages folder associated with the project I use and tried to reference it but received errors when trying to compile after adding the reference. Did you try:
                Code:
                using Microsoft.ML.Trainers.LightGbm
                This will compile without error.

                Comment


                  #23
                  https://learn.microsoft.com/en-us/do...=ml-dotnet-1.7.

                  Comment


                    #24
                    Sorry but I was wrong. It WON'T compile

                    Comment


                      #25
                      Click image for larger version

Name:	image.png
Views:	654
Size:	35.8 KB
ID:	1231664
                      Here are the error messages. Any ideas on how to fix?

                      Comment


                        #26
                        eleven

                        I figured it out. You need to make sure all the Microsoft.ML libraries that are dependent are the same versions. If you are adding the 1.7 version of LightGbm but the Microsoft.ML. is version 2.0 it will produce an error since both FastTree and LightGbm depend on Microsoft.ML. Also, LightGbm depends on Microsoft.ML.FastTree sou you'll need to load that one too. Finally, these are added onto the namespace ML.Microsoft.Trainers in the declarations. See the screenshot where intellisense now picks it up. I've confirmed this compiles:

                        Click image for larger version

Name:	image.png
Views:	681
Size:	67.1 KB
ID:	1231673
                        I still don't know how to fully access the features for the ModelInput methods. How are you doing it? Are you using the model builder in VS or just coding it all out in Ninjascript using the ML libraries?

                        Comment


                          #27
                          I keep getting this error:
                          Click image for larger version

Name:	image.png
Views:	671
Size:	200.4 KB
ID:	1231685

                          Comment


                            #28
                            Fixed and it all works! Thanks to all who replied with helpful suggestions! For future reference, it appears that in this instance the Path.GetFullPath method from the Model.Consumption.cs file attempts to reference the Model.zip file in C:Program Files/Ninja Trader 8/bin NOT where it is generated within the class library project folder. Copy the model zip file from the project folder and paste it into C:Program Files/Ninja Trade 8/bin folder.

                            Has anyone tried using NeuralNetwork.net libraries?

                            Comment


                              #29
                              Lance El Camino I got almost all the ML libraries to load last night. I am going to test it out tonight. Did you successfully train and evaluate the model data?

                              Comment


                                #30
                                I can successfully train and evaluate models, but I do it all in Visual Studio by adding the machine learning model to my project. Then I run it in their user interface by uploading a csv file created from indicator and chart data. Once trained and tested I use the Class1.cs project file as the class to reference in NT. I had to copy and paste all of the Model.Consumption.cs code from the generated model into that class object. Then that object is what I reference in NT along with the Microsoft.ML libraries that the Class.dll is dependent on. You need to reference each ModelInput property separately in the NT indicator unlike using the code snippet that ml.net creates. Also, you have to relocate the Model.zip file so it can be referenced by the Path.GetFullPath method properly.

                                Are you building the whole model within an indicator in NT? I prefer having class libraries built in VS doing most of the work and just using minimal code in the NT indicator. BUT, I really want to not have to output chart data to csv then upload csv to train the model. I'd like to be able to have the model train on assigned plots based on whatever indicators are loaded on the chart and bypass needing to load and train off of a csv file. This way it could also constantly retrain and update. Is this what you are going for?

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                560 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                325 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                101 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                547 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                547 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X