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

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 Christopher_R, Today, 12:29 AM
            0 responses
            9 views
            0 likes
            Last Post Christopher_R  
            Started by sidlercom80, 10-28-2023, 08:49 AM
            166 responses
            2,235 views
            0 likes
            Last Post sidlercom80  
            Started by thread, Yesterday, 11:58 PM
            0 responses
            3 views
            0 likes
            Last Post thread
            by thread
             
            Started by jclose, Yesterday, 09:37 PM
            0 responses
            8 views
            0 likes
            Last Post jclose
            by jclose
             
            Started by WeyldFalcon, 08-07-2020, 06:13 AM
            10 responses
            1,415 views
            0 likes
            Last Post Traderontheroad  
            Working...
            X