Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Visual Studio throws the same error message for all indicators I try to import

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

    Visual Studio throws the same error message for all indicators I try to import

    In two indicators written by Bard, it appears only once. In several imported from the ecosystem website, it appears three times, with identical wording.

    Here is the text:

    Unexpected null - line 98
    System.InvalidOperationException : Unexpected null - line 98
    at Roslyn.Utilities.Contract.Fail(String message,Int32 lineNumber)
    at Roslyn.Utilities.Contract.ThrowIfNull[T](T value,Int32 lineNumber)
    at async Microsoft.CodeAnalysis.Remote.BrokeredServiceConne ction`1.RentServiceAsync[TService](<Unknown Parameters>)
    at System.Runtime.ExceptionServices.ExceptionDispatch Info.Throw()
    at System.Threading.Tasks.ValueTask`1.get_Result()
    at async Microsoft.CodeAnalysis.Remote.BrokeredServiceConne ction`1.TryInvokeAsync[TService](<Unknown Parameters>)

    I suspect the problem will be obvious to anyone with some experience coding for NT8. Unfortunately, I'm not him. Or her.

    Could someone please tell me what is going on here and how to fix it?

    Many thanks.

    #2
    Hello owen5819,

    Do you see that happen if you create the indicator yourself or can you link one from the ecosystem that produces this error? While we cannot assist with AI generated code we can try to assist with questions you have about code that you have made. Its possible that the bard tool is generating invalid characters as the error mentiones null however the error really doesn't provide any helpful detail on what the problem is.

    Another note would be to not use visual studio and ensure the code can compile in the NinjaScript editor, the ninjascript editor is what does the compiling so it is possible that visual studio is just having its own issues with the code but is unrelated to NinjaTrader being able to compile.

    Comment


      #3
      When the AI code threw an error message, I decided I could not use Bard for coding. When I got the same error message with indicators from the ecosystem, it became clear the problem was mine, and I sought help. I will try again with the NinjaScript editor.

      Here are three indicators from the ecosystem that have produced the error message:

      My first indicator, a VWAP indicator similar to the included OrderflowVWAP, but should be usable in strategies and supports up to 5 deviation levels. Plus it looks dope out of the box. Happy to refine it if anyone has suggestions.

      NinjaTrader 8 natively provides Heiken Ashi as a bar type for most common bar types (minute, tick, volume, second, day, week, month, year). This Heiken Ashi indicator is provided for the Range, Renko and any custom bar types that may be added. The indicator performs in the same manner as the NinjaTrader 7 version. 4-27-18 [&#8230;]

      The Midas indicator was published in the July 2010 Stocks and Commodities article authored by Andrew Coles titled "An Anchored VWAP Channel For Congested Markets".

      Comment


        #4
        Hello owen5819,

        To further clarify, were you trying to build from visual studio? If so building is not currently supported, to use visual studio with NinjaTrader it only works to save documents and then the NinjaScript editor will detect that and compile.

        Comment


          #5
          When I try to import indicators from the desktop into the NinjaScript editor, it gives the following error message:

          "You have custom NinjaScript files on your PC that have
          "programming errors. These errors must be resolved before you
          "can import a NinjaScript Archive File."

          I have renamed all the .cs files on my desktop to .cs.bak, and the error message still appears.

          However, on a previous try, it found on the PC a file it identifies as NinjaTrader.NinjaScriptIndicators.AnchoredVWAP1. So far, I have not been able to find it myself. Neither, to my considerable frustration, can I copy it from the NinjaScript editor and send it as a text file.

          I did find several would-be indicator in my Documents folder and renamed them. No effect.

          It seems unlikely that my computer could somehow be changing the .cs files on their way to the desktop. However, to be sure, I will attach the files for the indicators linked to in the previous message.

          Midas.cs
          VWAPx.cs
          HeikenAshi8.cs

          Comment


            #6
            Hello owen5819,

            The message you are getting when trying to import items is because you have a compile error. That needs resolved before you can import anything.

            If you are manually renaming files in windows explorer please avoid doing that, manual changes often results in compile errors. Please always use the NinjaScript editor to do any kind of renaming, duplication, creation or deletion of scripts.

            Before doing anything else please follow the steps below to check for compile errors and to resolve them. Only after the errors are resolved will you be able to import scripts.
            1. Open NinjaTrader
            2. From the Control Center select the New menu--> select NinjaScript Editor
            3. Right-click in the window and select Compile to compile all NinjaScript objects
            4. At the bottom of the NinjaScript Editor window, a new section will appear where you can find the error locations
            5. You can exclude the file referenced in the editor by double-clicking on the appropriate object type on the right of the NinjaScript Editor window. This will expand the object type folder. You can then select the file with a left-click--> right click on the object--> then select Open to begin debugging the file, Exclude From Compilation, or Remove to delete the file.
            6. If you are unsure as to what the error is indicating, please send me a screenshot of the NinjaScript File column and Error column fully visible (not to be confused with the Code column)

            We have also collected more comprehensive steps for resolving NinjaScript programming errors in this tip in our Help Guide:
            https://ninjatrader.com/support/help...oom_highlights ub=how+do+i+resolve​

            Comment


              #7
              Many thanks for your help. I will delete all these files, download the indicators again to make sure nothing I have done corrupted them, and follow the instructions above.

              Comment


                #8
                And that did it. This time I downloaded the files directly to the desktop and told NT to import them one at a time. It worked smoothly. Apparently, moving the from the Documents directory to the desktop really did corrupt them. Many thanks for your help.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                576 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                334 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                553 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                551 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X