Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ML.NET project addition

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

    #31
    I'm trying to write the ML code in a NT strategy. Ultimately, I may need to take the approach you are taking with VS and NT. I will see how far I can get the next couple of days.

    You need to reference each ModelInput property separately in the NT indicator unlike using the code snippet that ml.net creates.
    Can you provide an example of the statement above? I think I might be running into this issue as well.

    Thanks,
    eleven

    Comment


      #32
      Here's what the model builder automatically generates as a code snippet for use in an app (my project is called CLNS2). I'll use the Volume feature as an example. It has an 'F' after the value because it has to be a float value. NT doesn't recognize this, you have to convert your variables to floats:

      Code:
      //Load sample data
      var sampleData = new CLNS2.ModelInput()
      {
      Volume = 1751429F,
      };
      
      //Load model and predict output
      var result = CLNS2.Predict(sampleData);
      Each of those properties (Volume) can't be referenced by NT in this format. Create a float variable that you can convert the series variable to a float. You can still instantiate the sampleData variable BUT need to call the properties differently. The series variable will take in that property:

      Code:
      float v = (float)Volume[0];
      
      var sampleData = new CLNS2.ModelInput()
      
      sampleData.Volume = v;

      Comment


        #33
        Thanks for sending the example code. I did not get a chance to work on this last night, but I have some free time over the weekend.

        Comment


          #34
          I want to give a special shoutout to Lance El Camino. This guy went above and beyond to help me set this up. He didn't have to help, but he did. Thank you sir for your willingness to share your experience.

          Comment


            #35
            Hi guys,
            I'm a bit familiar with Machine Learning however, how to implement this concept into trading futures is hard, particularly engineering the trading data for use with ML. Can someone please provide guidance on how to achieve this?

            Comment


              #36
              I'm trying to reference and load native assembly "CpuMathNative.dll" but I get an error that it is not in a .NET format. Is it possible to load this dll in NT8?

              Comment


                #37
                Originally posted by eleven View Post
                I'm trying to reference and load native assembly "CpuMathNative.dll" but I get an error that it is not in a .NET format. Is it possible to load this dll in NT8?
                I believe you have to change your project to a Net4.8 before building the project.

                Comment


                  #38
                  Originally posted by Nyman View Post
                  Hi guys,
                  I'm a bit familiar with Machine Learning however, how to implement this concept into trading futures is hard, particularly engineering the trading data for use with ML. Can someone please provide guidance on how to achieve this?
                  Create an indicator with all your indicators and values you want to use in your ML project as "Features" and write them to a CSV file, create your model, then use the same "Features" as inputs in your strategy to predict via the model. It sounds simple, but there is a huge learning curve. However, if you have past knowledge, it should be easier to pick up the terminology and implement the model. It was a huge curve for me, but doable. It took me two weeks of non-stop reading and fiddling to figure it out.

                  Comment


                    #39
                    Originally posted by click4payday View Post

                    Create an indicator with all your indicators and values you want to use in your ML project as "Features" and write them to a CSV file, create your model, then use the same "Features" as inputs in your strategy to predict via the model. It sounds simple, but there is a huge learning curve. However, if you have past knowledge, it should be easier to pick up the terminology and implement the model. It was a huge curve for me, but doable. It took me two weeks of non-stop reading and fiddling to figure it out.
                    click4payday, thank you so much for your response and guidance. I struggled with creating the target especially when there are many features. But now I got it.

                    Comment


                      #40
                      I was able to make ML.net work with my strategy using Web API method. I don't like using WebAPI but I don't see anyother option. I could not directly reference Project or dll generated by ml.net project. If anyone was able to make this work with directly referencing dll in NT, then please let me know how did you do it.

                      Comment


                        #41
                        Originally posted by Bhavin81 View Post
                        I was able to make ML.net work with my strategy using Web API method. I don't like using WebAPI but I don't see anyother option. I could not directly reference Project or dll generated by ml.net project. If anyone was able to make this work with directly referencing dll in NT, then please let me know how did you do it.
                        You don't have to use the Web API. If you have access Chatgpt 4o, you can ask how to use ML.Net without using a Web API. It will give detailed instructions and code on how to get it working with NinjaTrader.

                        Comment


                          #42
                          Thank you Click4payda. I will try it. I tried .net 4.8 application with ML.net but I did not try using nuget package installing ML in 4.8 project. I will try that way... thank you for the hint.

                          Comment


                            #43
                            I was able to get it all to work. The problem I have is developing a model that doesn't overfit the data. Anyone have luck so far?

                            Comment


                              #44
                              Lance El Camino I am starting out the process of adding ML.NET to NT. I found very useful information here. But I think that using weights is way to avoid overfitting, but you will need to do a gridsearch test/validate to find appropriate weight values.

                              Comment


                                #45
                                I have a full working example of how to properly load all the dll's into NinjaTrader and create an ML based strategy without having to call outside of NinjaTrader. It is a little hard to type out all the steps and can get a tad bit confusing with making sure all the proper things line up but feel free to email me and I can help walk anyone through it [email protected]

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                571 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                331 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
                                549 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                550 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X