Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Import Error After Updating to NinjaTrader Version 8.1.2.1

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

    Import Error After Updating to NinjaTrader Version 8.1.2.1

    Dear NinjaTrader Support Team,

    I am reaching out to report an issue I've encountered since updating to the latest version of NinjaTrader, version 8.1.2.1. Following the update, I attempted to export my custom code and encountered errors that prevented the export process. These errors were not present in the previous version.

    I have made several attempts to resolve these errors within my codebase without success. As a troubleshooting step, I reinstalled NinjaTrader, renaming the documents folder to "NinjaTrader 8 OLD" in accordance with instructions from an existing forum post, and performed a fresh installation of the platform.

    Note: I have tried installing a previous version (8.1.1.6) i had in my downloads folder and importing in this version as well but this did not work.

    Afterward, my partner successfully exported his custom code using the "Tools -> Export -> NinjaScript Add-on" function. However, when I attempted to import the exported files into my system, I encountered an import failure error. The error message suggests that the NinjaScript Archive File may contain duplicate method names, might modify a method signature that other scripts depend on, or could be missing a required file (please refer to the attached image for the exact error message).

    In an effort to isolate the issue, I removed entire categories of .cs files and attempted reimporting, but the error persisted. It was only when I significantly reduced the contents of my archive file, focusing on a specific .cs file and altering parts of its code, that I discovered the namespace might be the root of the problem. However, even after removing this particular script from the original archive file, I was still faced with the same error upon import.

    Prior to the update, I had not experienced any difficulties with exporting and importing my files. The recent issues seemed to have arisen after the new update and the addition of two interconnected classes (a strategy and an addon class that serves as an extension) to my code.

    Could you please provide guidance on how to resolve these import errors? I rely heavily on the ability to import and manage my extensive collection of custom strategies and addons, and this problem is significantly impacting my workflow.

    Thank you for your prompt attention to this matter. I am looking forward to your assistance in resolving these import issues.

    Best regards, Aviram Y.
    Attached Files
    Last edited by Aviram Y; 12-27-2023, 03:13 AM.

    #2
    Hello Aviram Y,

    Thanks for your post.

    You mentioned you were seeing errors when trying to export a script.

    What exactly was the error you were seeing when exporting the script so that I may accurately assist?

    This import error message does occur on previous versions of NinjaTrader. This message generally means there would be a conflict between something you have installed currently and what you are importing.

    You could manually install the item to test what the error is, if you are able to open the import screen and try to import the file, likely you don't have any compile errors so this would likely be a conflict in scripts.

    If this is a .cs file, the file could be manually imported for testing. If this is an indicator, you could copy the .cs file and paste it in the Documents\NinjaTrader 8\bin\Custom\Indicators folder. If this is a strategy file, you could copy the .cs file and paste it in the Documents\NinjaTrader 8\bin\Custom\Strategies folder.

    After pasting the file, open a New > NinjaScript Editor window and run a compile to check for errors. This could narrow down what is happening.

    Note that if you are importing a new version of a script you already have on your machine, make sure to remove that previous version, run a compile, and then import the new version to ensure there are no conflicts between scripts.​
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      ​I've added the errors in an image since this is what i saved before deleting everything.
      Click image for larger version

Name:	errors.jpg
Views:	124
Size:	50.7 KB
ID:	1283986​On the other part of your suggestions, i will try them out and let you know what i see.

      Comment


        #4
        Hello Aviram Y,

        Thanks for your notes.

        To clarify, have you created a copy of the CandleStickPattern indicator that comes default with NinjaTrader?

        Something you could try to resolve the compile errors is running a repair using the NinjaTrader installer.

        Please follow the steps below to run a repair using the NinjaTrader installer.
        • Close NinjaTrader if you have it opened.
        • Download the NinjaTrader installer from this link
          • account.ninjatrader.com
        • Once the installer is downloaded, run the NinjaTrader installer.
        • Click the Next button
        • Click the Repair button to run a repair.
        • After the repair is complete, exit the Installer
        • Restart NinjaTrader 8
        ​Let us know if this does not resolve the compilation errors.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the help Brandon.

          I'm not duplicating the CandleStickPattern indicator; it's used in my addon scripts, which extend my strategy scripts, like this: if(_strategy.CandlestickPattern(ChartPattern.Doji, 1)[0] == 1). I've done a repair and restart of NinjaTrader 8.

          The main issue now is different. After manually importing everything (strategies, indicators, and addons) and adding the Newtonsoft.Json .NET 4.5 dll to my custom folder and its reference in the editor, I face errors when exporting any class linked to my addon that uses Newtonsoft.Json. The errors indicate that 'Newtonsoft' namespace and 'JsonConvert' are not found. What should I do
          Errors:
          28/12/2023 17:43:17 Default Error compiling export assembly: C:\Users\avira\Documents\NinjaTrader 8\bin\Custom\AddOns\Classes\TradeDataCollector.cs( 22,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
          28/12/2023 17:43:17 Default Error compiling export assembly: C:\Users\avira\Documents\NinjaTrader 8\bin\Custom\AddOns\Classes\TradeDataCollector.cs( 146,35): error CS0103: The name 'JsonConvert' does not exist in the current context
          28/12/2023 17:43:17 Default Error compiling export assembly: C:\Users\avira\Documents\NinjaTrader 8\bin\Custom\AddOns\Classes\TradeDataCollector.cs( 120,30): error CS0103: The name 'JsonConvert' does not exist in the current context

          Code:
          #region Using declarations
          using Newtonsoft.Json;
          #endregion
          Code:
                  public async Task ExportAllTradeMetrics()
                  {
                      Print("exporting all trade metrics");
                      // Get the first trade account name.
                      string accountName = GetAllTrades()[0].Account;
                      if( accountName == "Backtest" )
                      {
                          // Serialize the entire trades dictionary to a JSON string
                          string allTradesDataJson = JsonConvert.SerializeObject(trades.Values.ToList());
          //                Print("all trades data json: " + allTradesDataJson);
                          var content = new StringContent(allTradesDataJson, Encoding.UTF8, "application/json");
                          try
                          {
                              HttpResponseMessage response = await client.PostAsync("http://localhost:5000/update_all_trades", content);
                              Print("sent batch http request");
                          }
                          catch (Exception ex)
                          {
                              Print("An error occurred: " + ex.Message);
                          }                
                      }
                      return;
                  }
          
                  public async void ExportTradeMetrics(Trade trade)
                  {
                      string tradeDataJson = JsonConvert.SerializeObject(trade);
          //            Print("tradeDataJson: " + tradeDataJson);
                      var content = new StringContent(tradeDataJson, Encoding.UTF8, "application/json");
          
          
                      try
                      {
                          HttpResponseMessage response = await client.PostAsync("http://localhost:5000/update_trade", content);
                          Print("sent http request");
          
                      }
                      catch (Exception ex)
                      {
                          Print("An error occurred: " + ex.Message);
                      }
          
                  }​​
          See references in the attachment.
          Attached Files

          Comment


            #6
            Hello Aviram Y,

            Thanks for your notes.

            Using third-party resources such as Newtonsoft in NinjaScript would be outside of what our support could assist with or provide samples of. This is something you will need to diagnose and work through on your end. You can use third-party references in your own programming but this is something you would need to reference in the NinjaScript Editor for it to work.

            Support for 3rd party assemblies is limited. Our team is able to assist with adding the dll and a reference to the dll, however we cannot assist with its use, or with any errors or unexpected behavior that may occur.

            With that said, we are happy to forward any insightful information we happen to be aware of.

            If this is a script you have written yourself, due to an internal change back on NinjaTrader version 8.0.26.0, calls to Newtonsoft must be made to an external .NET 4.8 equivalent or to the netstandard.dll.​

            Below is a link to the help guide on referencing a 3rd party assembly dll.
            https://ninjatrader.com/support/help...indicators.htm

            Additionally, if you plan to export the item, you would need to add the DLL to your export. https://ninjatrader.com/support/help...esOrNativeDlls

            Forum posts about JSON (newtonsoft.dll, netstandard.dll, System.Text.Json.dll) could be found below which you might find helpful:
            https://ninjatrader.com/support/foru...58#post1198058
            https://ninjatrader.com/support/foru...55#post1149655​​
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Segwin, 05-07-2018, 02:15 PM
            14 responses
            1,789 views
            0 likes
            Last Post aligator  
            Started by Jimmyk, 01-26-2018, 05:19 AM
            6 responses
            837 views
            0 likes
            Last Post emuns
            by emuns
             
            Started by jxs_xrj, 01-12-2020, 09:49 AM
            6 responses
            3,293 views
            1 like
            Last Post jgualdronc  
            Started by Touch-Ups, Today, 10:36 AM
            0 responses
            13 views
            0 likes
            Last Post Touch-Ups  
            Started by geddyisodin, 04-25-2024, 05:20 AM
            11 responses
            63 views
            0 likes
            Last Post halgo_boulder  
            Working...
            X