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

Scripts for building from VS & keeping folder structure

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

    Scripts for building from VS & keeping folder structure

    If you prefer to program in Visual Studio and have followed the instructions on these forums to get it set up but are still frustrated by the need to switch to the NT editor to build - and the inability to maintain a folder structure then here is a solution.

    Two powershell scripts attached. Create a "tools" folder in 'bin/custom' and add these.

    In visual studio project properties, add these lines to the post-build event:

    Code:
    Powershell -ExecutionPolicy  bypass -File "$(ProjectDir)\tools\Copy-Ninja-Temp.ps1" "$(ProjectDir)\MyProjects" "$(ProjectDir)\Indicator"
    
    Powershell -ExecutionPolicy  bypass -File "$(ProjectDir)\tools\Send-Keys.ps1" "Indicator - CompileMe" "{F5}"
    Move (don't copy) your NinjaTrader dev projects out of the strategy/indicator folder into "bin/custom/myprojects/project123/etc" - use whatever folder structure within that folder which suits you for your coding style.

    Keep an empty blank new indicator open in the NinjaScript editor called "CompileMe"

    Every time a build succeeds Visual Studio will run the post-build scripts.

    What the above post-build lines do, is recursively goes through all the files in $ProjectDir/MyProjects and copies all files to the indicator folder, with the file renamed to something like __temp_project1_codefile.cs.

    Then it sends an F5 keypress to the window with the title "Indicator - CompileMe" which is the Ninjascript editor - this will build and install everything in Ninjatrader.

    the next time you run it all the __temp files are cleared from the Indicators directory and copied over again.

    [update] looks like the Ninjascript editor needs to not be minimised for the Send-Keys operation to work.
    Attached Files
    Last edited by reach4thelasers; 09-01-2015, 07:45 AM.

    #2
    Hello reach4thelasers,

    Thank you very much for releasing this helpful information to everyone. I am sure many users who prefer coding in VisualStudio will appreciate your contribution.

    Please let me know if we may be of assistance anytime.
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      Thank you very much for this. You may be excited to hear that we have added Visual Studio integration into the NinjaScript Editor in NinjaTrader 8. With Version 8, all you have to do is save a file in your NinjaTrader.Custom project in Visual Studio, and the NinjaScript Editor will automatically update and compile.

      The only requirement is that the NinjaScript Editor remain open during the process (the same as with your process).
      Dave I.NinjaTrader Product Management

      Comment


        #4
        Wow that does sound very exciting Dave! Can't wait for it to be ready. While I have got the attention of a project Manager - did you see my post on order entry. Can you confirm if this is fixed in NT8? I realise that Forex is new to Ninja but with prices prices with 5 decimal places as we have in Forex, the current system really does not work for this market and entering orders is a very painful process. Details here:

        http://ninjatrader.com/support/forum...ad.php?t=77682

        Comment


          #5
          I did see that, and that is also taken care of in NinjaTrader 8. Any order-entry window that includes those price-entry fields (Basic Entry, FX Pro, FX Board, etc.) allows you to simply type a price directly into the field.
          Dave I.NinjaTrader Product Management

          Comment


            #6
            NinjaTrader, I'm glad to hear you added VS Studio integration in Ninja's editor, that's really good. Have you also added folder structure support for custom code?

            reach4thelasers, thanks for posting this, really helpful.

            As you noted in an update to the original post, the F5 keystroke to compile is not always sent to the NinjaScript editor window. It doesn't seem to be related to the fact it's minimized/maximized, but rather to the fact that another child window of NinjaTrader had the focus at last.

            I amended the "Send-Keys.ps1" to fix this, and it's working great here. It also generates an error in VS if the NinjaScript editor window is not found, which I find very convenient.
            Attached Files

            Comment


              #7
              Hello automated,

              Thank you for writing in. Unfortunately at this time the answer is that all custom code files must be top level to their respective folder. This feature request is being tracked in SFT-326 and I have added a vote on your behalf for this to be implemented.

              Please let me know if I may be of further assistance.
              Michael M.NinjaTrader Quality Assurance

              Comment


                #8
                I still use my powershell script for NT8 development. The new Ninjascript editor "sort of" allows "pseudo" folders - but all the files are flattened down to a single directory in the background. Because of this I had to make a copy of the whole Ninjatrader.Custom project and do my development in a different directory. The files get copied over as per the powershell script. If I did development inside the default project, Ninjatrader was doing its own copying and I had two copies of every type which obviously did not compile. Keepiing the folder separate gives me more control over my solution.

                Comment


                  #9
                  Another way to accomplish this

                  Another option is creating a junction (mklink /J "full path of junction directory" "full path to NT7 Custom directory" between the Visual Studio Workspace for your project and the NinjaTrader 7/Bin/Custom directory.

                  This eliminates the copying and renaming of files and lets you keep the directory structure in place that NinjaTrader 7 likes.

                  I took this approach so I could use the Source Control features in VS and keep things as normal as possible on the NT side things.
                  daqu40
                  NinjaTrader Ecosystem Vendor - QTradez

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by rtwave, Today, 01:49 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post rtwave
                  by rtwave
                   
                  Started by papaoutai, Today, 08:56 AM
                  0 responses
                  22 views
                  0 likes
                  Last Post papaoutai  
                  Started by jdspwe, Today, 05:22 AM
                  0 responses
                  13 views
                  0 likes
                  Last Post jdspwe
                  by jdspwe
                   
                  Started by JeremuFemstu, Today, 04:49 AM
                  0 responses
                  16 views
                  0 likes
                  Last Post JeremuFemstu  
                  Started by pjsmith, Today, 04:11 AM
                  1 response
                  22 views
                  0 likes
                  Last Post Green Lobster CBD  
                  Working...
                  X