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

Regenerating "Ninjascript Generated Code"

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

    Regenerating "Ninjascript Generated Code"

    Hi there,

    On previous versions of Ninjatrader, if I wanted to regenerate the "Ninjascript Generated Code" I would just switch to the Ninjascript editor, delete the generated code and save the file. The Ninjascript Generated Code would then be re-generated based on the Ninjascript Attributes etc.

    This approach seems to have stopped working for me, how do I get this code to re-generate?

    Thanks,

    Kevin.

    #2
    Hello kevinenergy,

    That process still works, are you compiling from that indicator after deleting the code? Saving the indicator would not generate the code, that is only saving the file.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hey Jesse,

      thanks for responding so quickly. This seems to have stopped working for me for some reason. I usually just delete the generated code and hit ctrl-s when I want it regenerated. This triggers the re-generation of the code and runs a compile.

      I've tried deleting the code and then clicking the compile button but it has the same effect: the code does not appear and the compile fails. Any idea why this might not be working? It has been quite some time since I needed to do this.

      Thanks,

      Kevin
      Last edited by kevinenergy; 04-21-2021, 08:40 AM.

      Comment


        #4
        Hello kevinenergy,

        Saving the file from the NinjaScript editor won't trigger a compile or generate the code, you would need to press F5 to compile F5 which also saves so generally you can just avoid using save.

        The problem could relate to your script, you may want to try and generate a new empty indicator and check that you can do the process from that script. If you find that this relates to your custom script only then you may need to debug the script to find what part is causing that to not generate. That could include putting custom classes or enums above the indicator class in the file.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse,

          I've come up with a workaround.

          The problem is the way I develop for Ninjatrader is unconventional and at some point, my ways have become incompatible with the code generation. I code in Visual Studio outside of Documents/Ninjatrader/Custom and when I trigger a compile in Visual studio a post-build task copies all my personal code into Addons folder in Documents/Ninjatrader/Custom. The Ninjascript editor detects the change and builds it. It looks like there's been a change to Ninjatrader at some point where the Addons folder doesn't trigger the regeneration of "Ninjascript Generated Code". I literally dump all my indicators, strategies, bartypes into a subfolder inside Addons, just to keep everything together. It builds fine when you do that. But if you delete the Ninjascript generated code it no longer regenerates in the addons folder.

          I can get around it for now by pasting the code into a temp file in the indicators/strategies folder and it regenerates there. I expect if I update my post-build script to copy everything into the Indicators folder things will work the way they used to.

          Anyway I have come up with a way around the problem.

          Thanks for responding

          Kevin.

          Comment


            #6
            Hello kevinenergy,

            From the given details all I can really suggest is to use the supported development approach and just click the visual studio toolbar button to open the custom project in visual studio. That would correctly detect changes you make when saving, I couldn't assist with the other process you described.

            The addons folder also should not generate any indicator generated code, only the indicators folder will have that action applied to the files in that folder.

            By moving the files into other types folders you will eventually see issues as the platform is not expecting you do to that. I would not suggest trying to develop in that way. Our support also cannot provide accurate help when you ask questions because that is not the correct file structure for NinjaScript objects.

            While you can try to work around it that is not advised as you will likely continue hitting issues going forward.

            Please let me know if I may be of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              I understand there's limited assistance you can give with my unconventional approach. But I've been doing it this way since the very early versions of Ninjatrader 8 in 2016 and it works extremely well for me.

              Back then there was no visual studio button and no way to make a custom folder structure in the Ninjascript Editor, I have written over 700 individual C# code files and a fair amount of WPF XAML for Ninjatrader over the years, so my codebase is very complex and the conventional ways don't work well for me for a number of reasons:

              - I don't like how the Ninjascript editor recompiles every time a file change happens (its watching the filesystem so even external changes trigger a build) - visual studio with resharper is slow enough without the Ninjascript editor trying to build code that's not ready. so I prefer to code outside of the main Ninjatrader folder, and trigger a manually with ctrl-shift-b in visual studio which triggers a compile, and my post-build script then copies all the files over to the Ninjascript folders when I'm ready for the Ninjascript editor to build the assembly. Otherwise my machine is constantly chugging away trying to build code that isn't ready every time a file change happens.
              - I also use Git for my source control and had a whole world of problems having git running in Ninjatrader's working folder.

              But yes I accept that my unconventional approach is likely to lead to issues, but will adapt when necessary. I've now changed my build script to copy my entire 700 file codebase into Indicators/MyProjects rather than Addons/My Projects and - the regeneration works of "Ninjascript Generated Code" works fine again. Compilers don't care about folders - just about namespaces, so it works fine to dump everything there, even things that aren't indicators. It helps keep all my code together, and the code generation now works from the indicators folder.

              It really would be great if there was a separate folder-tree in Ninjascript explorer for user-specific code, containing all the usual subfolders: Indicators, Strategies etc. When you've got a lot of code it really is a pain to find things mixed in with all the stock Ninjatrader stuff, which is another reason why I do things my way. Maybe take this as a feature suggestion?

              Thanks for the support.

              Kevin.
              Last edited by kevinenergy; 04-22-2021, 02:47 AM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Brevo, Today, 01:45 AM
              0 responses
              3 views
              0 likes
              Last Post Brevo
              by Brevo
               
              Started by aussugardefender, Today, 01:07 AM
              0 responses
              3 views
              0 likes
              Last Post aussugardefender  
              Started by pvincent, 06-23-2022, 12:53 PM
              14 responses
              240 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              9 responses
              384 views
              1 like
              Last Post Gavini
              by Gavini
               
              Started by oviejo, Today, 12:28 AM
              0 responses
              6 views
              0 likes
              Last Post oviejo
              by oviejo
               
              Working...
              X