Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What is good workflow for developing custom indicator and strategy with git?

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

    What is good workflow for developing custom indicator and strategy with git?

    I am developing a custom indicator and strategy. What is the best practice for a development workflow, especially when I am tracking my code with Git. I also have the following specific questions below:

    1) I want to have two copies of my custom indicator. One is the main indicator and one is the development version. I was hoping to have a folder, filename and class name structure as below. One issue I noticed is I cannot have two different custom indicators with the same class name. Thus the below structure won't work. How can I distinguish between my main indicator and my dev version of the indicator. If change the classname to distinguish between the main and dev version (e.g. FooBar_dev), it works but it is not my preferred method because when I want to save the dev version as the main I have to go change some of the code manually.

    FolderA/FileB.cs >> Classname: FooBar
    FolderA/FileB_dev.cs >> Classname: FooBar

    2) Is it possible for Ninjatrader to refer to Indicators/Strategies that are outside the folder: C:\Users\MyUsername\Documents\NinjaTrader 8\bin\Custom\ ? Since I am developing both Indicators and Strategies, I would have to have two different Git repos in each of their unique folders. I prefer to do all my dev and testing with Indicators/Strategy code located in a different folder, for example C:\Users\MyUsername\​Desktop\MyProject.

    #2
    Hello wzgy0920,

    This thread will remain open for other community members to voice their opinions.

    Note, C# cannot have duplicate class names. All class, property, and method names within the same scope must be unique.
    You will need to use a different class name for a copy of the indicator.

    It is possible to put scripts in folders. In the NinjaScript Editor right-click the Indicators folder and select New Folder. Then drag the indicator into the folder.

    No, scripts that are not in Documents\NinjaTrader 8\bin\Custom will not be compiled into NinjaTrader.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      No, scripts that are not in Documents\NinjaTrader 8\bin\Custom will not be compiled into NinjaTrader.
      I noticed every time I save my script, Ninjatrader adds modifies and appends some additional code. It is the section that says "#region NinjaScript generated code. Neither change nor remove.". What happens if Ninjatrader is NOT open, and I modify the script? Will it recompile and append the autogenerated code it needs?

      Comment


        #4
        Hello wzgy0920,

        The overload wrappers are generated automatically to allow the indicator to be called by a host strategy or host indicator.

        No, the generated code will not generate unless the script is compiled in the NinjaScript Editor.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I do my development outside of the "Documents/Ninjatrader 8" folder. My dev environment is: C:\Users\Kevin\dev\Ninjatrader


          I created a new visual studio solution there and copied the Ninjatrader.Custom project from Documents\Ninjatrader 8\bin\Custom and added it to the solution. This is my Development environment.

          Inside this dev environment copy of Ninjatrader.Custom, I have a folder called "My Projects" where I do my custom development. This has all the usual Ninjascript folders (Indicators, Strategies, DrawingTools etc. Plus some others, e.g. Common/Interfaces/Models. All the other Folders outside of "My projects" are left untouched. These contain all the default indicators, barstypes that come packaged with ninjatrader. And you will likely reference these from your code.

          This is my Dev environment. I have this set up for git. using visualstudio azure online, but github works just as well in visual studio. .

          I have a post-build task set up in Visual Studio that uses Robocopy to copy the MyProjects folder from C:\Users\Kevin\Ninjatrader\MyProjects over to the Ninjatrader folder.

          Code:
          (robocopy /mir "$(ProjectDir)\MyProjects" "C:\Users\kevin\Documents\NinjaTrader 8\bin\Custom\Addons\MyProjects") ^& IF %ERRORLEVEL% GEQ 8 exit 1
          Every time I do a build in Visual Studio. If the build is successful (no errors) then the post-build script runs. The script then dumps the entire MyProjects folder into the "Addons" folder. Robocopy is configured with the /mir flag which checks to see what files have changed and only copies the ones that have.

          When the files are copied, the Ninjascript editor (which is permanently left open & minimized) automatically detects the change and builds the Ninjascript assembly. The compiled code is then instantly available within Ninjatrader.

          I've been doing it this way for more than 6 years and it is pretty seamless.


          Click image for larger version  Name:	visual studio.png Views:	0 Size:	557.3 KB ID:	1270994
          Last edited by kevinenergy; 09-29-2023, 07:35 PM.

          Comment


            #6
            i use github project which imported my ninjatrader solution. i do have a dev instance, backtest instance and a trading instance.
            dev instance:
            i added to the .gitignore all the NT related files/language files /templates etc as i will not touch them.

            Click image for larger version

Name:	WmJ6ouT.png
Views:	611
Size:	32.7 KB
ID:	1271054
            my workflow is manual as i use github desktop to pull the chnages to default folders and leverage winmerge to compare and copy the changes/new files
            i like Kevin's model too. i may try it in future.

            Comment


              #7
              Kevin's way is great. Here's another similar setup without the robocopy-ing of files and which also allows you to use the NinjaScript Editor. In the Custom directory, open a shell terminal (command prompt).

              Code:
              cd "%USERPROFILE%\Documents\NinjaTrader 8\bin\Custom"
              git init
              Then create a .gitignore file in the root of Custom. Let's say you want to put all your scripts in a directory called "MyCompany" for each type of resource you create (e.g.: Custom\Indicators\MyCompany\MyIndicator.cs, Custom\Strategies\MyCompany\MyStrategy.cs).

              Code:
              # Ignore everything (we don't need NinjaTrader files checked in)
              *
              
              # Unignore directories (to allows exceptions below)
              !*/
              
              # Unignore the MyCompany directories for each type of resource
              !.gitignore
              !README.md
              !AddOns/MyCompany/**
              !BarsTypes/MyCompany/**
              !ChartStyles/MyCompany/**
              !DrawingTools/MyCompany/**
              !Indicators/MyCompany/**
              !Strategies/MyCompany/**
              Create a README.md file in the root of Custom:

              Code:
              # MyCompany NinjaScripts
              
              Scripts and AddOns for NinjaTrader 8
              Back in the command prompt, git commit your files (first create an empty private repo in GitHub, and note down the git url if using ssh, or use the http url to the repo):

              Code:
              git add .
              git commit -m "First commit"
              git remote add origin [email protected]:mycompany/myrepo.git
              git push -u origin main
              Your code should now be on GitHub.

              To deploy to a different server, you can use the direct ZIP link on GitHub. Download the repo zip files from your branch's archive url: https://github.com/mycompany/myrepo/...heads/main.zip ...

              Click image for larger version

Name:	image.png
Views:	253
Size:	80.1 KB
ID:	1341366

              Unzip the files into your Custom directory. Trade on.

              Use tagging and releases in GitHub to stamp versions of your repo. Use branches while developing and until you merge your branches into main, your deployments using your main branch ZIP url won't pick up any WIP development.
              ​​

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              108 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              55 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              37 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              38 views
              0 likes
              Last Post TheRealMorford  
              Started by Mindset, 02-28-2026, 06:16 AM
              0 responses
              75 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X