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

How to view Ninjascript in Visual Studio or other editors

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

    How to view Ninjascript in Visual Studio or other editors

    I have not had any success being able to view ninjascript files like Strategies within external editors. The probem is I can't figure out how to view the class outline. IntelliJ, VS Code, Atom, Sublime, etc... all failures

    So finally I installed Visual Studio 2019 community edition... thought it would be easy. But I can't figure it out there either.

    There is something called class view but it is just empty when I open an addon I created.

    What am I doing wrong?

    #2
    Hello NinjaCustomer,

    To use visual studio with NT8 you would need to first open the NinjaScript editor and then click the Visual Studio button in the toolbar. This opens the NinjaTrader.Custom project in visual studio.

    The class view in visual studio is only used if you have a visual studio project open. If you are just opening a file in visual studio by its self you would only see code coloring, otherwise, the class view would be empty and the other code features like intellesense are disabled.


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

    Comment


      #3
      do you know of any editor that can parse a c# file, seems like a simple thing but I have had no success... I installed VS studio on my other machine and I'd rather not install it on my main machine for now. I don't need to debug , I just am used to editing source code with an outline view when the file gets large

      Comment


        #4
        Hello NinjaCustomer,

        You can use Visual Studio or the NinjaScript editor as both can view/edit the .cs file. Outside of these tools, any text editor could be used however only visual studio or the NinjaScript editor will give the correct and complete overview of the custom project.

        If you are trying to use any language features like intellesense or have the ability to see the class structure, that will require using the NinjaScript editor or opening the visual studio solution. You can use other text editors to just edit the file but would be unable to use the more complex C# highlighting, intelleprompt, code completion etc..

        You can do a google search for "C# editor" for some ideas of what can open cs files, really their just a text file so it depends on what other language features you require. If you just need to edit the file with no other completion or highlighting you could use notepad or basically any text editor in that use case.



        I look forward to being of further assistance.

        JesseNinjaTrader Customer Service

        Comment


          #5
          ok, i guess I'll have to install visual studio when I free up enough space on my drive. Unfortunately C# IDEs and Editors with addons like VSCode, Atom, etc. out there don't really seem to be able to parse ninja .cs . I don't know what is wrong with it but they don't like it. Some even crash like the SharpDevelop IDE.

          Comment


            #6
            Hello NinjaCustomer,

            While I can't provide any information with the crash I can say that I would expect the result of not being able to correctly view NinjaScript files in any case where the Visual Studio project is not being used.

            Any editor which is not opening the custom project will not have the full context of whats what's on inside of the script you are viewing. If you look at the visual studio project from inside of visul studio there are many references and other items being incorperated which creates "NinjaScript". Without the references and other scripts being included, most of the syntax of the script won't make sense to the editor being used. This is the same concept if you take a single .cs file out of a C# applications project and try to view it outside of its original context, it won't make a lot of sense to the IDE without the full solution.


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

            Comment


              #7
              should I be able to compile in Visual Studio 2019 the custom solution?

              I get a lot of errors if I try build

              or should I keep a ninjscript editor open and view the errors there after I save in VS 2019?

              also I created a local git in VS 2019 for it, but VS 2019 seems to want to make it in the ninjatrader custom folder - would you know how I could move it outside, so it is not a subfolder of NinjaTrader 8 folder?

              Comment


                #8
                Hello NinjaCustomer ,

                should I be able to compile in Visual Studio 2019 the custom solution?
                or should I keep a ninjscript editor open and view the errors there after I save in VS 2019?
                No, VS is being used as just a text editor in this case. This means the NS editor needs to be left open while editing in visual studio. When you save, NnjaTrader compiles.

                You can ignore the warnings you see in visual studio, errors will display there, however, the NinjaScript editor will be in charge of the compile so would be the correct location to check for errors as well.

                also I created a local git in VS 2019 for it, but VS 2019 seems to want to make it in the ninjatrader custom folder - would you know how I could move it outside, so it is not a subfolder of NinjaTrader 8 folder?
                You would not be able to use the source control or other features like adding references, nuget etc from visual studio. NinjaTrader is compiling so all items need to be completed through the platform. If you want to make your own project which includes items visual studio offers, you would need to not use the NinjaTrader custom project and create an addon.


                see AddOn Development Environment (Visual Studio Advanced)

                When you click the VS button in the toolbar, that is opening the project Documents\NinjaTrader 8\bin\Custom\NinjaTrader.Custom.csproj which the platform manages. It's one directional, if you add a reference in VS, NT will not see that change and will overwrite it on the next compile. The same would go for other features like source control, it's going to want to use the project root which is the custom folder which is where NinjaTrader manages this project from.


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

                Comment


                  #9
                  ok thanks for the explanation. VS seems good at spotting errors before compile anyhow, so it is definitely more productive than the NinjaScript editor.

                  Comment


                    #10
                    I tried to follow these instructions: https://ninjatrader.com/support/help..._debugging.htm

                    but I'm running into problems

                    When I try to set a breakpoint it says it won't be hit, because symbol information can't be loaded. (I've attached the process already to NinjaTrader.exe)

                    I also disabled "Just My Code" in the debug options of VS but that didn't help.

                    If I try to right click NinjaTrader.exe in Module View and "Symbol Load Information" then it gives a bunch of error messages about .pdb not being found for various files.

                    Before launching VS from the NinjaScript Editor, I enabled debug mode

                    Comment


                      #11
                      Hello NinjaCustomer,

                      Did you compile after enabling debug mode? That is the only item that was not noted here that would be needed.



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

                      Comment


                        #12
                        nope, I men apart from it compiling when I save VS but that would probably have been prior to debug mode and attaching

                        do you mean compile in ninjascript editor? should that be done while it is attached or before it is attached but after debug mode is enabled?

                        Comment


                          #13
                          Hello NinjaCustomer,

                          Yes, again you won't do any compiling in VS so any mention of compile will always refer to in NinjaTrader. A compile would be needed to generate the PDB file after debug mode has been enabled. You can do the compile at any time after debug mode is enabled, while you are attached or not. If you compile and it does not pick it up, try reattaching.


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

                          Comment


                            #14
                            Hey Jesse, I've been using VS a lot lately, and wonder if there's a better way to do what I am doing...

                            So I run a strategy, with breakpoint set, poke around and want to edit the code. Seems I need to then
                            a) stop debugging
                            b) edit code (mostly I do this in VS)
                            c) Save (in VS)... which triggers NS recompile
                            d)... then, I need VS to reattach to the NS process

                            Is there a better workflow? Or is this as good as it gets?
                            Sorry if this really should be in a new thread, but it seemed close to the original topic...

                            Cheers,

                            Comment


                              #15
                              Hello tgn55,

                              That is a process you can follow however you can usually stay attached to the process during compiles. You would only need to make sure to press "Continue" if you were stopped at a breakpoints first so that the platform can recompile.

                              The general process I can see working on my end is:
                              1. Run strategy, set break point
                              2. Hit breakpoints
                              3. press Continue
                              4. Edit script
                              5. Save script
                              6. Breakpoints are now white
                              7. Compile happens
                              8. Breakpoints becomes red again after reloading pdb
                              9. Re test

                              The whole process I remain attached to the platform. I am sure there can be situations where you need to also detach and re attach so these steps likely don't apply across the board. Doing simple edits to an existing file will allow this process to work.

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

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by nandhumca, Today, 03:41 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post nandhumca  
                              Started by The_Sec, Today, 03:37 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post The_Sec
                              by The_Sec
                               
                              Started by GwFutures1988, Today, 02:48 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by ScottWalsh, 04-16-2024, 04:29 PM
                              6 responses
                              33 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by frankthearm, Today, 09:08 AM
                              10 responses
                              36 views
                              0 likes
                              Last Post frankthearm  
                              Working...
                              X