Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimizing strategy with machine learning

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

    Optimizing strategy with machine learning

    In order to optimize my strategies using machine learning algorithms, I need to acquire data of all wining and losing trades during backtesting, in a first step. Is there an infrastructure to log this data in csv-file?
    In a second step, I would like to recalculate the models at certain intervals during strategy runtime. Are there libraries available to calculate and use Random Forests, Support Vector Machines, etc.?

    #2
    Hello rafe0304,

    Thank you for your post.

    I am not aware of any libraries but there are several resources available when researching online.

    You can export any grid report by right clicking in it and selecting Grid. The options available will export in different ways. For information on Grids please visit the following link: http://ninjatrader.com/support/helpG...data_grids.htm

    Comment


      #3
      Hi Patrick,

      Thank you for your answer.

      In my strategy , I want to train and retrain a random forest (or any other suitable machine learning library) during session breaks, such that I can base my trading decisions in the subsequent session on the trained model. To do that, I need two things:

      1. data about all my historic trades executed in the strategy
      2. Inclusion of 3rd party .net machine learning libraries

      Now I can see, how I would accomplish the 1. point. But how can I include third party libraries in my strategy script?

      Comment


        #4
        Hello rafe0304,

        Thank you for your response.

        When calling a library you would need to refer the .dll file by right clicking in your NinjaScript Editor (in any file) and then selecting References > Add > locate the file > Open.
        Then in your NinjaScript object that needs to call the library add a 'using' statement at the top where the region 'Using declarations' is located with the other using statements.

        Comment


          #5
          Seeing this one a bit late. Implementing a RF or SVM module isn't too hard really. You need to collect the data internally in your indicator/strategy into a separate time series and then pass that to the DLL that encapsulates all those functions. I take it you know how to add a 3rd party lb into NinjaTrader by now.

          Originally posted by rafe0304 View Post
          Hi Patrick,

          Thank you for your answer.

          In my strategy , I want to train and retrain a random forest (or any other suitable machine learning library) during session breaks, such that I can base my trading decisions in the subsequent session on the trained model. To do that, I need two things:

          1. data about all my historic trades executed in the strategy
          2. Inclusion of 3rd party .net machine learning libraries

          Now I can see, how I would accomplish the 1. point. But how can I include third party libraries in my strategy script?

          Comment


            #6
            Do you have machine learning example script?

            Comment


              #7
              I think I am Late for this post, since it has been going on for a while. I have been working with Machine learning for a couple of years now. You can try Accord.Net. Its a nice library that has machine learning algorithms. If you are into neural networks, Encog is a simple solution. to save the data into a CSV file, you need to create your own code, should be easy to do. you train the Classifier/ Regressor outside of Ninjatrader, serialize it, and load it into your strategy or indicator. I would not even try to predict price, since its likely going to be futile( I tried it at the beginning, looks beautiful on training, but useless on validation data). its better to classify patterns of price movement, market conditions, filter bad trades, and things like that. I use regression to create a cone of possible price movement, but even that fails during strong trends. The issues you are going to run into, is coming up the tools to collect and analyze the data, that's where my challenge was.

              Comment


                #8
                Hi Yandychang , which tool or api do you use to download the price data from NT and train your model?
                I am planning in using tensorflow (python) to train and tune the models.
                Thanks in advance!

                Comment


                  #9
                  You would need to load the data on an indicator. There is no api for that.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by siroki, Today, 03:22 AM
                  0 responses
                  9 views
                  0 likes
                  Last Post siroki
                  by siroki
                   
                  Started by nailui, Today, 03:01 AM
                  1 response
                  10 views
                  0 likes
                  Last Post NinjaTrader_Jason  
                  Started by an.fedorov, Today, 02:32 AM
                  0 responses
                  10 views
                  0 likes
                  Last Post an.fedorov  
                  Started by rustyspring, Today, 01:31 AM
                  1 response
                  13 views
                  0 likes
                  Last Post NinjaTrader_Jason  
                  Started by op1031, Today, 12:26 AM
                  0 responses
                  12 views
                  0 likes
                  Last Post op1031
                  by op1031
                   
                  Working...
                  X