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

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.

    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        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.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            19 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            179 views
            0 likes
            Last Post jeronymite  
            Started by ghoul, Today, 06:02 PM
            0 responses
            9 views
            0 likes
            Last Post ghoul
            by ghoul
             
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            13 views
            0 likes
            Last Post DanielSanMartin  
            Started by DJ888, 04-16-2024, 06:09 PM
            4 responses
            13 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Working...
            X