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

Error exporting strategy that uses custom common code

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

    Error exporting strategy that uses custom common code

    I have a strategy that uses custom code such as extension methods, common classes that I share between strategies, etc. I put this code in a directory called Libraries that is at the same level as the Strategies directory. All of the code in the Libraries directory uses a namespace of NinjaTrader.NinjaScript.Libraries.

    The strategy compiles and works fine on my machine, but when I try to export it, it gives me the error

    "Error compiling export assembly: ..... error CS0246: The type or namespace name [class name here] could not be found (are you missing a using directive or assembly reference?)"

    I know what this error means, but how do I resolve it when exporting a strategy? I looked in the References of the export utility and didn't see anything that looked promising to include with my strategy. Is there another namespace I should be using or should I put my custom common code in another place for NinjaTrader's export utility to pick up?

    #2
    Are you including the files in the libraries directory when you do your export? You have to specifically select them and select your strategy also. If you have put your files in bin -> Custom -> Libraries rather than a Libraries subdirectory in AddOns and it its files are not showing up in the export dialog I would recommend you move that Libraries directory into AddOns and change your namespace accordingly.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Originally posted by furman87 View Post
      I have a strategy that uses custom code such as extension methods, common classes that I share between strategies, etc. I put this code in a directory called Libraries that is at the same level as the Strategies directory. All of the code in the Libraries directory uses a namespace of NinjaTrader.NinjaScript.Libraries.

      The strategy compiles and works fine on my machine, but when I try to export it, it gives me the error

      "Error compiling export assembly: ..... error CS0246: The type or namespace name [class name here] could not be found (are you missing a using directive or assembly reference?)"

      I know what this error means, but how do I resolve it when exporting a strategy? I looked in the References of the export utility and didn't see anything that looked promising to include with my strategy. Is there another namespace I should be using or should I put my custom common code in another place for NinjaTrader's export utility to pick up?
      My first suggestion:
      Take your file(s) out of the Libraries folder and locate them directly into Strategies
      folder. Then make sure to include them when selecting files to export.

      Since these are extensions and common classes, I would suggest you use your
      own namespace, such as 'Furman.Libraries', this removes all possibilities for
      any type of conflict anywhere down the line.

      These are easy experiments.

      As a last resort, move your code somewhere else and use Visual Studio to
      pre-compile your code into a separate DLL, then copy that DLL to bin/Custom
      and add it as a reference.
      Last edited by bltdavid; 05-03-2023, 09:37 AM.

      Comment


        #4
        Hello furman87,

        Bruce is providing great information.

        Also, below is a link to a video.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          You devoured this page, right?

          Comment


            #6
            bltdavid raises an excellent point. You should not call your library Library or Libraries because another developer could make the same mistake and then the two of you have a conflict - that's a bit like naming your strategy Strategy.cs. Make it specific in its naming to you or your project.
            Bruce DeVault
            QuantKey Trading Vendor Services
            NinjaTrader Ecosystem Vendor - QuantKey

            Comment


              #7
              Thanks for everyone's suggestions, I was able to get what I needed by moving my code under the AddOns directory as Bruce suggested. I also changed the namespaces as Bruce and bltdavid suggested.

              Once everything was in AddOns, it showed up in the Export dialog so that it could be included in the export, which is what I needed.

              Comment


                #8
                Excellent. Glad it's working for you now.
                Bruce DeVault
                QuantKey Trading Vendor Services
                NinjaTrader Ecosystem Vendor - QuantKey

                Comment


                  #9
                  Hi furman87 I tried to send you a message on here but the platform does not allow it. Can you please reach out to me at my username at gmail.com? It's about discussing a private script...thanks

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Jonafare, 12-06-2012, 03:48 PM
                  5 responses
                  3,985 views
                  0 likes
                  Last Post rene69851  
                  Started by Fitspressorest, Today, 01:38 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post Fitspressorest  
                  Started by Jonker, Today, 01:19 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post Jonker
                  by Jonker
                   
                  Started by futtrader, Today, 01:16 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post futtrader  
                  Started by Segwin, 05-07-2018, 02:15 PM
                  14 responses
                  1,792 views
                  0 likes
                  Last Post aligator  
                  Working...
                  X