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

SVM possible in NT8?

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

    SVM possible in NT8?

    Hello all,

    I have become increasingly more interested in the prospect of implementing machine learning into my trading, there is one article in particular that piqued my interest.



    He/She uses a support vector machine to find optimal values for trading the RSI. I found the article in the NT8 support forum on this thread...



    However, that thread sort of fizzled out without much follow up or interest, or any real NT8-oriented projects.

    My question is, is it possible to recreate what this person has done with the RSI using the R programming language, but by using Ninjascript editor and some other indicator?

    If so, what tools are available to make this happen? Can I add the Using Directives I need to implement a so-called "off the shelf" SVM (support vector machine) in C# and start testing things? I tried one and it said I may be missing an assembly?

    Anyway, I hope you all have some ideas about what avenues I could take to make this happen, and please keep in mind, I am pretty well-versed in NinjaScript, but I learned C# within that context. Which is to say, it's not as if I tried everything a top-notch programmer would try and it didn't work, I really am just asking for a nod in the right direction, and general ideas of what is/isn't possible within NinjaScript in the context of machine learning and SVM's, and what tools for this exist in NT8 that I may be unaware of.

    Anyway, look forward to hearing from you. Thank you!


    #2
    I haven't run TensorFlow Machine Learning Code In C# myself and don't know what NinjaTrader compatibility issues there might be, but thought you would find this article interesting.

    Run TensorFlow Machine Learning Code In C# With Almost No Changes

    Comment


      #3
      Hello lunardiplomacy,

      Thanks for your post.

      From the NinjaScript Editor and Strategy Analyzer we are limited to performing the backtest types that are available in the platform. Additional backtest types would not be possible to build as an AddOn. The backtest portion is really key to be able to have machine learning create a strategy, test it, and make comparisons with other generated strategies.

      We do have an AI Generate strategy which is in experimental phases which can perform some machine learning with a Genetic Algorithm with the indicators on your platform, but this may not be identical to the study you have linked.

      You can read more about the AI Generate backtester here - https://ninjatrader.com/support/help...i-generate.htm

      I'll leave the thread open for discussion with Community Members who have experimented with machine learning and automated trading strategies.

      We look forward to assisting.
      JimNinjaTrader Customer Service

      Comment


        #4
        Originally posted by caveat_lector View Post
        I haven't run TensorFlow Machine Learning Code In C# myself and don't know what NinjaTrader compatibility issues there might be, but thought you would find this article interesting.

        Run TensorFlow Machine Learning Code In C# With Almost No Changes
        Ah, thank you for the contribution, Caveat. This looks like a good place to start.

        Not even sure how I would link this into NinjaScript though. Maybe a NT support has some ideas on this, or has some familiarity with it?

        I think if I can get this package into the NET core I should be able to add it by References...>Add, but like I said I have no idea how that would function or how to even download it into the NET core like in the article. I know it provides the code, but like I said, I have only ever developed within NinjaScript.

        Any ideas on this?

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello lunardiplomacy,

          Thanks for your post.

          From the NinjaScript Editor and Strategy Analyzer we are limited to performing the backtest types that are available in the platform. Additional backtest types would not be possible to build as an AddOn. The backtest portion is really key to be able to have machine learning create a strategy, test it, and make comparisons with other generated strategies.

          We do have an AI Generate strategy which is in experimental phases which can perform some machine learning with a Genetic Algorithm with the indicators on your platform, but this may not be identical to the study you have linked.

          You can read more about the AI Generate backtester here - https://ninjatrader.com/support/help...i-generate.htm

          I'll leave the thread open for discussion with Community Members who have experimented with machine learning and automated trading strategies.

          We look forward to assisting.
          Hey Jim! Thanks for the reply.

          Right, it probably makes more sense to build models/perform testing outside of the context of NT8 and then simply port the rules that the SVM defines into NinjaScript.

          That being said, do you have any familiarity with/recommendations for platforms/data analysis tools that are capable of this?

          Would I be able to export the historical data I have from NT8 into whatever data analysis tool I end up using and train models with it?

          Look forward to your reply, thank you!

          Comment


            #6
            Hello lunardiplomacy,

            I can't comment on other platforms or tools that offer machine learning features for generating automated trading strategies, but community members here may have some thoughts. We would like to hear feedback for the AI Generate strategy, as well, so I would suggest checking that out and sharing your experience with us so we can make improvements as this tool is further developed.

            As for backtesting data on other platforms, you would want to get a little more familiar with how their backtesters work. For example, NinjaTrader processes the historical OHLC values and also uses these values to simulate order fills. If High Order Fill Resolution is used, you could be filling orders with a different data series. Other platforms may just use Close to simulate order fills. If you create our own backtesting engine outside of NinjaTrader, you are free to design how it fills orders and can build it so it can use data exported from the platform.

            If you want to reference the formats for data, please see here - https://ninjatrader.com/support/help...AndDataFormats

            We look forward to assisting.
            JimNinjaTrader Customer Service

            Comment


              #7
              Jim,

              Thanks so much for taking the time. I am rereading the AI Generate literature and this is certainly where I am going to start. I was under the impression that custom indicators cannot be used in this context, but it looks like that isn't true. Maybe that was strategy generator that I was thinking of.

              I will let you or another staff member know if I am able to accomplish what I seek to accomplish, and in what ways the code base could be altered to improve.

              The engine is quite impressive, by the way.

              Thanks.
              Last edited by lunardiplomacy; 04-09-2020, 11:13 AM.

              Comment


                #8
                Right, it probably makes more sense to build models/perform testing outside of the context of NT8 and then simply port the rules that the SVM defines into NinjaScript.
                The various AI methods self-optimize in attempts to achieve user-defined fitness criteria. In some cases the result is a set of relatively simple rules that could be easily coded in NinjaScript. However, that isn't always true. For example, TensorFlow is exceptionally good at image recognition. Though that capability is commonly used in applications like facial recognition, it also can be used to identify complex trading patterns that deceptively occur in many variations that are difficult for humans to quickly identify, or sometimes even be able to see after much study. If used for something like that it would be necessary to have TensorFlow (or some alternative AI engine) interfaced so that it could analyze and act according to trading patterns as they develop in real-time.

                Comment


                  #9
                  Originally posted by NinjaTrader_Jim View Post
                  Hello lunardiplomacy,

                  I can't comment on other platforms or tools that offer machine learning features for generating automated trading strategies, but community members here may have some thoughts. We would like to hear feedback for the AI Generate strategy, as well, so I would suggest checking that out and sharing your experience with us so we can make improvements as this tool is further developed.

                  As for backtesting data on other platforms, you would want to get a little more familiar with how their backtesters work. For example, NinjaTrader processes the historical OHLC values and also uses these values to simulate order fills. If High Order Fill Resolution is used, you could be filling orders with a different data series. Other platforms may just use Close to simulate order fills. If you create our own backtesting engine outside of NinjaTrader, you are free to design how it fills orders and can build it so it can use data exported from the platform.

                  If you want to reference the formats for data, please see here - https://ninjatrader.com/support/help...AndDataFormats

                  We look forward to assisting.
                  Hello again, Jim.

                  Just fyi, I looked into using AI Generate in order to accomplish my goals, and while it is a very impressive tool, I was correct initially that it cannot take custom indicators as parameters and so my feedback would be to add that functionality. Please add my vote to that specification if it exists. Putting in the resources to allow users that kind of flexibility would make ninjatrader an even more powerful platform than it already is, thank you.

                  Comment


                    #10
                    Hello lunardiplomacy,

                    Custom indicator support for single series indicators was added in Release 21. I'll check with Product Management on Monday to see what their intentions are for multi time frame indicators.

                    EDIT: We don't have immediate plans for Multi Time Frame custom indicator support in AI Generate and will be tracking interest in a feature request. I will update this post with a ticket ID when it becomes available. Ticket ID: SFT-4056

                    We are also aiming to improve how performance results are weighed so strategies with 1 profitable trade are not weighed higher than strategies with multiple trades.

                    Release Notes for Release 21 - https://ninjatrader.com/support/help...8/8_0_21_1.htm
                    Last edited by NinjaTrader_Jim; 05-12-2020, 03:17 PM.
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      Ah! that is very good news, Jim. Thanks for letting me know. I read in the official docs that it did, but then also remember having read on the forums that it did not.

                      In case you are interested, here is a link to the forum post that caused the discrepancy

                      Very excited to see that NinjaTrader now has an automatic strategy generator.. great work ! Few questions though.. - The new strategy generator only seems to


                      I will provide more comprehensive feedback once I have actually attempted to implement it rather than skimming over the code. I appreciate the time you have taken.

                      Comment


                        #12
                        Most of the wrappers for Tensorflow are for .NetStandard V2.0 which is not yet supported by Ninjatrader. I integrated tensorflow throw a restful api. It works but it is very slow for back-testing purpose. If anyone knows of a wrapper compatible with .net framework 4.5 please post.

                        Comment


                          #13
                          I also intend to use a tensorflow model and I imagine a model deployed with tensorflow services via grpc would be able to do predictions, but may not be the optimal solution for backtesting the strategy in NT.

                          Originally posted by jortuzar View Post
                          Most of the wrappers for Tensorflow are for .NetStandard V2.0 which is not yet supported by Ninjatrader. I integrated tensorflow throw a restful api. It works but it is very slow for back-testing purpose. If anyone knows of a wrapper compatible with .net framework 4.5 please post.
                          jortuzar, can you elaborate more on the wrapper needed? I've done plenty of indicators and strategies in NT8, but I'm no expert in C# and I don't know the differences of the .net frameworks.
                          Do you know if these libraries work for deploying a Tensorflow model in NT8? Which wrapper did you use?
                          Keras.NET is a high-level neural networks API for C# and F#, with Python Binding and capable of running on top of TensorFlow, CNTK, or Theano. - GitHub - SciSharp/Keras.NET: Keras.NET is a high-le...

                          .NET Standard bindings for Google's TensorFlow for developing, training and deploying Machine Learning models in C# and F#. - SciSharp/TensorFlow.NET


                          Thanks in advance

                          Comment


                            #14
                            Correct. Anything besides library wrappers where you can pass memory objects (tensors) directly, will be slow for back testing. I have yet to try running python directly from c# (through CLR). Not sure that works.

                            I have found that you can do a big part of the back-testing directly in python. There are many plots and other data visualization tools you can use to get an idea if this is going to work or not. I'd say 80% of the back-testing can be done this way. Then you can just run it with playback and get a real feel for the results.

                            Maybe the Ninjatrader techs can shed some light. Would also be useful to know when theyethey to upgrade the system to .netstandard 2.0. This request has several years.

                            Comment


                              #15
                              Hello,

                              There is not much additional insight we can give for using tensorflow. You can include ,NET 4.5 compatible DLL's in the Documents\NinjaTrader 8\bin\Custom folder and add a reference to that DLL in the NinjaScript Editor (Right Click > References.) Note that dependencies must also be included.

                              As far as upgrading the .NET framework used in NinjaTrader 8, this would likely be done in a major update and would not be done in the minor Release updates we have been pushing. We are tracking interest for upgrading the .NET framework used, and I have noted your interest in a vote. The ticket ID for upgrading NinjaTrader 8's .NET framework is SFT-3124.

                              We look forward to assisting.
                              JimNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jclose, Today, 09:37 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post jclose
                              by jclose
                               
                              Started by WeyldFalcon, 08-07-2020, 06:13 AM
                              10 responses
                              1,414 views
                              0 likes
                              Last Post Traderontheroad  
                              Started by firefoxforum12, Today, 08:53 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post firefoxforum12  
                              Started by stafe, Today, 08:34 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post stafe
                              by stafe
                               
                              Started by sastrades, 01-31-2024, 10:19 PM
                              11 responses
                              169 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X