Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exporting Indicator as Assembly when using Partial Classes

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

    Exporting Indicator as Assembly when using Partial Classes

    I have created a simple AddOn in the AddOns folder that looks like this:
    Code:
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public partial class Indicator
        {     
            public string CoolString(string str){
                return str;
            }    
        }
    }
    I am able to use it in an Indicator like this:
    Code:
                else if (State == State.Configure){
                    Print(CoolString("test"));
                }
    It all works fine but when I attempt to Export the Indicator and check the box to export as a Complied Assembly, I get the error below:
    Code:
    Error compiling export assembly: c:\Users\scooke\Documents\NinjaTrader 8\bin\Custom\Indicators\CoolIndicator.cs(51,11) : error CS0103: The name 'CoolString' does not exist in the current context
    I don't understand why it compiles and works just fine but will not export.

    #2
    Hello swcooke,

    Thank you for the post.

    Are you exporting both the indicator and the addon together when you see this error? The partial class will need to be exported in addition to the indicator, when making a compiled assembly that code is no longer part of the source code you have on your machine so all code used needs to be included.

    I look forward to being of further assistance.

    Comment


      #3
      Thanks Jesse. I just tested and now it exports fine. One more question. I am using a third-party library in the form of a dll file. On my development machine, I simply compiled this to a dll and dropped it into the Custom folder. That seems to work fine. When I export as a compiled assembly, I check the box in the Export window that shows my dll as a Reference. I thought this would mean when a user Imports what I have exported, my dll is part of the export. Instead, they are being shown a message that indicates they need that dll file. I thought that it would be compiled into my assembly. Is this not the case? How can I make sure that what I export, can be imported on the user's machine, seamlessly without the user being alerted that they are missing a resource to something?

      Comment


        #4
        Hello swcooke,

        The additional reference is not able to be compiled into your DLL because you are not using the source code for that reference. That would specifically be a referenced file so this is the same for the end user.

        To include references you would need to choose the reference during the export which generates the message you mentioned. This also creates an additionalreferences.txt file in the export. You can find the full steps to include the dll reference in the following page: https://ninjatrader.com/support/help...esOrNativeDlls

        After adding the .dll and ensuring the additionalreferences.txt file exists in the zip, the end user should be able to import and also have the item referenced.

        I look forward to being of further assistance.

        Comment


          #5
          I have the source code for the reference. It's just an open source library with some helper functions I use. Instead of me creating a dll out of it, is there a way to alter my workflow so that it is compiled directly into what NT exports so my users don't have to deal with it?

          Comment


            #6
            Hello swcooke,

            If you have the source code you would just use that instead of referencing the dll, this would similar to the other files you see in the NinjaScript editor. Without knowing the specifics of the library I couldn't really say if that will be able to be compiled from within the platform, but you can certainly try if you wanted to.

            I look forward to being of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            606 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            353 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            560 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            561 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X