Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Errors When Importing NinjaTrader Strategy with Newtonsoft.Json.dll Dependency

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

    Errors When Importing NinjaTrader Strategy with Newtonsoft.Json.dll Dependency

    Subject: Resolving Errors When Importing NinjaTrader Strategy with Newtonsoft.Json.dll Dependency

    Hello fellow traders,

    I am seeking assistance with an issue I encountered while attempting to share a NinjaTrader strategy that utilizes the Newtonsoft.Json.dll library. The strategy works perfectly on my local machine, as I have the necessary DLL installed. However, when I try to import the strategy onto a fresh NinjaTrader installation on a different machine, I am faced with several compilation errors related to the Newtonsoft namespace and its associated types.

    Here are the specific errors I am receiving:

    ```
    Time Category Message
    6/17/2024 6:40:29 AM Default Error compiling import assembly: C:\Users\Owner\Documents\NinjaTrader 8\tmp\Import\Files\bin\Custom\Strategies\AvantAlgo KingMaker.cs(23,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

    Time Category Message
    6/17/2024 6:40:29 AM Default Error compiling import assembly: C:\Users\Owner\Documents\NinjaTrader 8\tmp\Import\Files\bin\Custom\Strategies\AvantAlgo KingMaker.cs(102,20): error CS0246: The type or namespace name 'JsonException' could not be found (are you missing a using directive or an assembly reference?)

    Time Category Message
    6/17/2024 6:40:29 AM Default Error compiling import assembly: C:\Users\Owner\Documents\NinjaTrader 8\tmp\Import\Files\bin\Custom\Strategies\AvantAlgo KingMaker.cs(65,25): error CS0246: The type or namespace name 'JObject' could not be found (are you missing a using directive or an assembly reference?)

    Time Category Message
    6/17/2024 6:40:29 AM Default Error compiling import assembly: C:\Users\Owner\Documents\NinjaTrader 8\tmp\Import\Files\bin\Custom\Strategies\AvantAlgo KingMaker.cs(65,46): error CS0103: The name 'JObject' does not exist in the current context

    Time Category Message
    6/17/2024 6:40:29 AM Default Error compiling import assembly: C:\Users\Owner\Documents\NinjaTrader 8\tmp\Import\Files\bin\Custom\Strategies\AvantAlgo KingMaker.cs(24,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
    ```

    I would greatly appreciate any guidance on how to resolve these errors and ensure that the strategy can be seamlessly imported and used by others without the need for manual DLL installation.

    From my understanding, the issue stems from the absence of the Newtonsoft.Json.dll library on the target machine. I have tried including the DLL file in the compiled assembly zip file, but it doesn't seem to be recognized during the import process.

    Is there a specific way to package the DLL alongside the strategy files to ensure a smooth import experience? Or are there any alternative approaches to handle this dependency that I should consider?

    Thank you in advance for your assistance and insights
    Best regards,
    Andrew​

    #2
    Originally posted by Tradewave View Post
    The strategy works perfectly on my local machine, as I have the necessary DLL installed.
    Did you install the same DLL on the new machine, too?

    Try that, then retry the import.

    Comment


      #3
      I did not. I am not sure how I installed it originally. I think it may have been an import zip file. Do you know where I would be able to get the dll ? I think I would need to download it from Nuget. But not sure entirely what that process entails.

      Comment


        #4
        Hello Tradewave,

        If this is not something you created and are just trying to import the file the best way would be to download the original zip that you imported on your first PC, that will allow you to import the file and also have the reference added that the developer originally used. If you no longer have the zip file or cannot download it you would need to see which file was referenced when you originally imported it, you can do that by opening the NinjaScript editor -> Right click -> References and locate the dll. That same reference would need to be added to the other PC in the same location.

        This also depends on the versions of NinjaTrader being used. To make sure this works the same version of NinjaTrader should be used, if the other PC is using an older version it may not be able to use the version of Newtonsoft that your pc is using. NinjaTrader updated to a newer version in release 8.1.2.0

        If this is a script that you are creating and plan on exporting you would need to follow the steps in the following page to include the dll used as part of the importable zip file.

        https://ninjatrader.com/support/helpGuides/nt8/index.html?distribution_procedure.htm#AddingCustom AssembliesOrNativeDlls​

        Comment


          #5
          I was able to fix this issue. All I need to do is add the newtonsoft.json.dll file in the Custom folder and it worked.

          Comment


            #6
            I got this error:

            The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

            ...when trying to add
            using Newtonsoft.Json;

            to a project.

            I then downloaded newtonsoft .zip for version 13.0.3 from github and copied the version 4.0 DLL to the custom folder, and restarted NT. But I get the same error. I checked mu machine and I have installed .NET v2, v3, v3.5, v4 and v4.0.

            Any idea how to fix?

            Comment


              #7
              Hello DerkWehler,

              You can use the version that comes with NinjaTrader by referencing the file from the directory C:\Program Files\NinjaTrader 8\bin. You will need to remove the ones you manually added along with the reference in the NinjaScript editor first and restart the platform.

              Comment


                #8
                There is nothing in bin except custom folder.

                I was able to fix it; realized I needed to right-click on the editor, choose References...

                Then add, and locate and select the DLL.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Today, 05:17 AM
                0 responses
                52 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                130 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                70 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                44 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                49 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X