• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Install Package in NinjaScript Project

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

    Install Package in NinjaScript Project

    I am trying to use a model from tensorflow in a Ninjascript. There are a couple of wrappers but for .netstandard 2.0 and not .netframework 4.5.
    I open the Ninja Custom project in VS 2019 and was able to install the TensorFlowSharp package using the Install-Package command.

    However when I try to compile a Script in NT8 with a reference to the package I get the error: "namespace name tensorflow was not found". What's interesting is that I don't get this reference error within the VS project.

    Is there a special way to install packages that can be used in ninjascripts?

    Thanks

    #2
    Hello Capablanca,

    For NinjaTrader references that will need to be a .net framework reference version 4.5 or less.

    Nuget is not something which is supported, while you can use that in visual studio that will have no effect on the NinjaTrader project. NinjaTrader manages the visual studio project so adding references or any changes will need to be made using NinjaTrader. You can think of visual studio as just a text editor in this use case, it won't do any compiling.

    You can use the NinjaScript editors reference menu to add references however those files need to be placed in the folder: Documents\NinjaTrader 8\bin\Custom and cannot reside in any external folder or sub folders. You may want to try creating a .net 4.5 visual studio project and see if there are nuget references for what you want, if so add them to that project and build the project. Look in the bin folder for what was built and then you can try to copy those resources to the bin/custom folder and reference it in NinjaTrader.

    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse!
      Thanks for your answer. I was able to compile the script in the NinjaScript Editor following your instructions!

      I also noticed that if I open the project with Visual Studio and install the package, the files are added to the folder NinjaTrader8/bin/Custom/packages, and then they need to be referenced.from the NinjaScript Editor.

      The code I'm trying to implement is pretty simple and I already tested it in a VS project .net 4.5. and the only library I need is in order to encode/decode json files (link below).

      However I am now getting the following error when running the strategy PredictionTensorflowModel.zip :

      Code:
      Strategy 'TestingTensorflowModel': Error on calling 'OnBarUpdate' method on bar 0: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
      Am I missing another reference?
      The DLL is in the folder \NinjaTrader 8\bin\Custom\packages\Newtonsoft.Json.12.0.3\lib\n et45\Newtonsoft.Json.dll

      Thanks in advance!
      Json.NET is a popular high-performance JSON framework for .NET

      Comment


        #4
        Hello Capablanca,

        I also noticed that if I open the project with Visual Studio and install the package, the files are added to the folder NinjaTrader8/bin/Custom/packages, and then they need to be referenced.from the NinjaScript Editor.
        Please don't try to manage nuget with the custom project, I had noted the reasons for this in my last post. The custom project is not a good candidate for making changes because it will be regenerated by NinjaTrader and is only used as a text editor. This will not place the files in the correct locations if you use nuget and will add other unneeded build data to the custom folder which is bad.

        The files need to be manually copied and placed in the folder bin/custom, that is the only location where they can be loaded from so nuget will not work from the custom project. To keep the NinjaTrader folder clean you can use an external project of your own (on your desktop or somewhere else) to collect files, ultimately you need to manually copy everything to the bin/custom folder ensuring all needed references or resources are present.


        The other error you mentioned is that the dll is not found, if the dll was not placed in the bin/custom that is the reason.
        You can use the NinjaScript editors reference menu to add references however those files need to be placed in the folder: Documents\NinjaTrader 8\bin\Custom and cannot reside in any external folder or sub folders.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello Jesse,

          I hope I didn't break the project with the Nuget installations. :/

          I did as you initially said, and everything is working now.
          Thank you very much for your help!

          Comment


            #6
            Hello Capablanca,

            Code:
            I hope I didn't break the project with the Nuget installations. :/
            No you likely did not, however because nuget pulls in a lot of different types of files that can place files in the custom folder which can try to be compiled. That wouldn't be dlls but could include other misc source files like .cs files. It is best to keep the custom folder pretty much limited to your custom content and not anything extra like other VS solutions/build data/exported zips/backups of excluded ninjascript data, etc..

            Please let me know if I may be of additional assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jayfutures23, Today, 07:06 AM
            0 responses
            1 view
            0 likes
            Last Post jayfutures23  
            Started by gbvryetd, Today, 06:52 AM
            0 responses
            2 views
            0 likes
            Last Post gbvryetd  
            Started by jdobgsvs, Today, 06:42 AM
            0 responses
            3 views
            0 likes
            Last Post jdobgsvs  
            Started by Spark68, Yesterday, 07:48 PM
            1 response
            17 views
            0 likes
            Last Post NinjaTrader_PaulH  
            Started by Lotyok, Today, 01:08 AM
            4 responses
            25 views
            0 likes
            Last Post NinjaTrader_PaulH  
            Working...
            X