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

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:	196
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

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by fredericlebre, Today, 01:19 AM
            0 responses
            2 views
            0 likes
            Last Post fredericlebre  
            Started by TraderJA, Today, 12:06 AM
            0 responses
            4 views
            0 likes
            Last Post TraderJA  
            Started by SnailHorn, Yesterday, 10:49 PM
            0 responses
            7 views
            0 likes
            Last Post SnailHorn  
            Started by naanku, Yesterday, 07:25 PM
            0 responses
            8 views
            0 likes
            Last Post naanku
            by naanku
             
            Started by milfocs, Yesterday, 07:23 PM
            0 responses
            6 views
            0 likes
            Last Post milfocs
            by milfocs
             
            Working...
            X