Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

R Statistics Program Integration / Interoperability

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

    R Statistics Program Integration / Interoperability

    Hi,

    Can NT team add a feature that integrates or interoperates with R program suite natively with NT?

    That would be an invaluable asset to NT capability.

    Can it be done on NT8 or would it have to be next major release if considered?

    #2
    Hello ericson,

    Just to make sure we are on the same page, you refer to the R Project for Statistical Computing at the link below, correct?
    JasonNinjaTrader Customer Service

    Comment


      #3
      Correct. Im using R.net to interoperate, but it can be difficult to utilize and is limited.

      Comment


        #4
        Hello ericson, and thank you for your question.

        While this is normally outside the scope of the support we provide, I am leaving this thread up so the community can weigh in. I will also try to provide some resources myself which should help you get started.

        First, the publicly available link to the third party R.Net platform I believe we are discussing is here, please review this link and let me know if this is incorrect.



        Since it will be useful for general education and will allow us to answer other user's questions quickly, I am preparing an add-on which uses C#'s DllImport methods to lazily load symbols from a dll during runtime. While this will load from kernel32.dll , the code I provide should be adaptable to the third party R.Net product, and I will use their code as a test case for the code I provide. Direct support for their product will not be available in the add-on I provide.

        Should you desire the services of a NinjaScript consultant for a complete end to end solution, please let us know.

        I will return to this thread when I have more information.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Yes that is the correct resource. More specifically this one.

          .NET interop library to call the R statistical language in the same process - rdotnet/rdotnet


          I have it running in NT8. The issue is not being able to run more than one R.net engine instance, ie two or more indicators running it simultaneously. I need r.net to to able to run multiple, separate instances for each implementation in indicators.

          Here are some more resources about the issue, but it is beyond my programming skills to solve.

          R.NET is an in-process interoperability bridge to R from the .NET Framework. R.NET requires .NET Framework 4 and the native R DLLs instal...




          Thats why im asking NT team to develop a better, perhaps native in application, interop system with R. R would be an extremely valuable expansion for NT.
          Last edited by ericson; 02-21-2017, 03:37 PM.

          Comment


            #6
            I am attaching a simple add-on which loads a .dll file in a lazy fashion. I have also learned from this publicly available stack overflow discussion,

            In fact, I got a C++ (working) DLL that I want to import into my C# project to call it's functions. It does work when I specify the full path to the DLL, like this : string str = "C:\\Users\\user...


            that C# lazily loads .dll files by default. This means that if these things happen in order

            • you start Ninja without the library you'd like to call in your (My) Documents\NinjaTrader 8\bin\Custom folder
            • you programmatically copy the library you'd like to call from into this folder
            • you use DllImport in a fashion similar to that in the attached add-on
            • the very first call to the imported method occurs

            then you will be able to sequentially load .dll files. To sequentially load the same dll twice, simply give it two different names in your filesystem.


            Generally speaking, the attached add-on is again intended only to demonstrate how to use DllImport from a NinjaScript Add-On. Its use as anything other than an educational aid is not guaranteed.



            Please let us know if there are any other ways we can help.
            Attached Files
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              I wanted to address this separately.

              The issue is not being able to run more than one R.net engine instance, ie two or more indicators running it simultaneously.
              C# already provides the ability to create critical sections in code (linked documentation publicly available) easily through use of the lock variable. This will ensure that only one instance from one thread is accessing any segment of code at one time. If you restrict all your calls to any R methods to this section, due to C#'s lazy initialization by default mentioned earlier, this will have the effect you described by itself. This help guide page demonstrates using the lock keyword in its sample code.

              Jessica P.NinjaTrader Customer Service

              Comment


                #8
                ok thank you!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Waxavi, Today, 02:10 AM
                1 response
                17 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Started by Kaledus, Today, 01:29 PM
                5 responses
                13 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by Waxavi, Today, 02:00 AM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Started by alifarahani, Today, 09:40 AM
                5 responses
                23 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by gentlebenthebear, Today, 01:30 AM
                3 responses
                17 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X