Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

A button in Visual Studio to trigger NinjaScript Compilation.

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

    A button in Visual Studio to trigger NinjaScript Compilation.

    Another never-be-implemented request, but just as a typical entry, i will leave:
    It would be a good to add one button in toolbar of Visual Studio (here is a sample of it), so clicking on that button, should trigger the "compile" of NinjaScript Editor (exactly when we click F5 in NS editor).
    So, we could work on indicators in VS, without need to use NinjaScript editor, which lacks many simples notepad functionalities even (requested many timed, but they will never been implemented as i see), so we could work in Visual Studio, and changes would reflect quicker, without need of Restart of Ninjatrader.
    I've tried this code, but fails in Visual Studio:

    Code:
                bool ShowErrors     = true;
                bool ShowWarnings   = false;
                try
                {
                    var result = NinjaTrader.Code.Compiler.Compile(true, false, null, null);
                    for (var i = 0; i < result.Errors.Count; i++)
                    {
                        if ( (ShowErrors && ! result.Errors[i].IsWarning) || (ShowWarnings && result.Errors[i].IsWarning) )
                        {
                            string msg = (result.Errors[i].IsWarning ? "Warning" : "Error") + " ::: " + result.Errors[i].ErrorText;
                            Console.WriteLine(msg);
                        }
                    }
    
                }
                catch(Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
    However, this code works when run inside NT editor. So, all i want to say, it will be good if NT had an addin (button) for Visual Studio, to do that.

    neither this worked:

    Code:
           
    NinjaTrader.Gui.HotKeys.NinjaScriptEditorHotKeys x= new NinjaTrader.Gui.HotKeys.NinjaScriptEditorHotKeys();
    x.Compile();
    or
    Code:
    var x=new RoutedUICommand("Compile", "Compile", typeof(NinjaTrader.Gui.Tools.NTWindow));
    x.Execute(this, null );
    Last edited by ttodua; 02-25-2019, 01:38 PM.

    #2
    Hello TazoTodua,
    Thanks for your post.

    You do not need to restart NinjaTrader for Visual Studio changes to take effect. Not sure what you have going on there.

    As long as you have the NinjaScript Editor window open, anytime you save in Visual Studio it will compile automatically. I have my Visual Studio set up so that I save with F5 and then NinjaTrader will automatically compile for me.

    The ability to manually compile from Visual Studio is an existing feature request, so I will add a vote on your behalf. The internal tracking number for that feature request is SFT-209. Please reference this internal tracking number if you ever have questions regarding this feature request.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_JoshG probably I didnt explain well? two problems:

      1) You need to have NT IDE open (what is not convenient though)
      2) When you save file in Visual Studio (either with F5 or without it), it will need several seconds until NT IDE checks the "Custom" directory for file changes (in my case, it might be 5 seconds or more or less), and after it sees changes, it starts re-compiling. I want to achieve instant trigger of "compile" action, like when I do in nt with F5. Otherwise, I have to switch to NT IDE and click f5 there, when I want quick recompiling.

      When you said that after clicking F5 in VS, how quickly NT ide starts recompiling in your case?

      Comment


        #4
        TazoTodua,

        1) You need to have NT IDE open (what is not convenient though)
        I agree, the convenience factor of not having the NS Editor open is what makes this an attractive feature request.


        When you said that after clicking F5 in VS, how quickly NT ide starts recompiling in your case?
        My platform compile about 4-5 seconds after pressing F5 in Visual Studio. For me at least, this is about the same amount of time it takes to compile the same script from within the platform. The difference is negligible.
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Josh, I think I should have asked it differently. I wanted to ask, when clicking F5 in VS, does compilation starts immediately in NS, or after 4-5 seconds?
          On my side, the NT doesnt at all re-compile, even after X minutes. Can you show me a screencast how it's done? here see on my side, it doesnt happen: https://files.fm/u/ffrm7wqa


          Even after I will see your way how NT recompiles itself after F5-ing in VS, this suggestion still is nice.
          Compiling without open NT-ide will be nice. I think, there should be some observing to the Custom.dll file, lets say when F5 triggers in VS, the NT should raise some flag to re-compile all it's scripts. and in case an errors, the NT Editor should be opened up in that case, pointing to those error-lines, like regularly it's shown.

          I've tried to achieve that with the code i've suggested in the top post, tried to put it in addon and check last filestamp date of Custom.dll file, to trigger automatic recompilation, without need of NT IDE open, but couldnt succeed, i think it need a bit more effort.
          Last edited by ttodua; 02-27-2019, 05:10 AM.

          Comment


            #6
            TazoTodua,

            The NinjaScript Editor will automatically compile whenever you save in Visual Studio. So I have my VS installation setup with F5 as a shortcut for File>>"Save selected items". You will need to set up the same hotkey first before you can expect to compile with F5 in VS.

            Please see the following public link for information on how to set up shortcuts in VS:


            I agree that this would be a useful feature request as well.
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              NinjaTrader_JoshG can you show me a small screencast (or not for me, just for everyone) how you do? because in the above post, I've shown a video to you that I've tried but it doesnt do for me.

              I tried Save, Build, Rebuild (see that video) but it doesnt do. I am just asking how to do it with plain menu clicks (without F5 shortcut... after I find how it works then i can assign keyboard shortcut, yes).
              thanks

              Comment


                #8
                TazoTodua,

                There really isn't anything to show in a screencast. You simply save the file in VS while the NS Editor is open. If you have the NS Editor window open you would select File>>Save selected items in Visual Studio in order to compile.

                In the screenshot below it would be "Save NinjaTrader.Custom", but that will be replaced by the file you are currently editing.

                Click image for larger version

Name:	VSMenu.png
Views:	279
Size:	16.2 KB
ID:	1049649

                Josh G.NinjaTrader Customer Service

                Comment


                  #9
                  yes, but the recompilation is not happening in NS editor. I've tried enable debug-mode, but still not. ok, thanks, seems something broken in my NT.

                  Comment


                    #10
                    Thanks, I've found out that problem was that i used `symlinked`(mirrored) folders in NinjaTrader.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by funk10101, Today, 12:02 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post funk10101  
                    Started by gravdigaz6, Yesterday, 11:40 PM
                    1 response
                    7 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by MarianApalaghiei, Yesterday, 10:49 PM
                    3 responses
                    10 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by XXtrader, Yesterday, 11:30 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post XXtrader  
                    Started by love2code2trade, 04-17-2024, 01:45 PM
                    4 responses
                    28 views
                    0 likes
                    Last Post love2code2trade  
                    Working...
                    X