Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

duplicating code question

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

    duplicating code question

    i went to the "C:\Documents and Settings\dflorendo\My Documents\NinjaTrader 6\bin\Custom\Strategy" directory to find a strategy .cs file i wanted to duplicate....

    copied and pasted in the same folder...then renamed the test.cs


    then I went in and renamed the class to "test"
    then removed everything in the Initialize() and OnBarUpdate()
    I added a new code to OnBarUpdate()..

    then compiled it fine...

    but when I go to backtest this file... In the output window, I get Initialize() code from a different .cs file...

    what am I doing wrong?
    thanks

    #2
    Please delete this file via Tools > Edit NinjaScript > Strategy.
    Then to properly copy a file, open the file you wish to copy in the NinjaScript Editor, then right click and select "Save As", NT will take care of all required changes etc...
    RayNinjaTrader Customer Service

    Comment


      #3
      just gave that a try..

      it still executed the Initialize() function from a different file...

      Originally posted by NinjaTrader_Ray View Post
      Please delete this file via Tools > Edit NinjaScript > Strategy.
      Then to properly copy a file, open the file you wish to copy in the NinjaScript Editor, then right click and select "Save As", NT will take care of all required changes etc...

      Comment


        #4
        I would then suspsect you are really running the file that you think you are not. Please make sure that the display names for both files are different and that you select the right one to run.
        RayNinjaTrader Customer Service

        Comment


          #5
          come to thing of it...
          no matter which strategy files i execute (included the default strategy files)
          it plays the Initialize() of one particular file...


          something unique about this files is that particular file is that I used the Print() function within Initialize()... every strategy file I run displays the output from this particular file...

          any ideas?

          Originally posted by NinjaTrader_Ray View Post
          I would then suspsect you are really running the file that you think you are not. Please make sure that the display names for both files are different and that you select the right one to run.

          Comment


            #6
            Yes, this is expected. When you open the strategy dialog, Initialize() is called for all strategies in the dialogue. If you have a Print() statement in there, it will execute.

            The strategy to you select to run will still run of course.
            RayNinjaTrader Customer Service

            Comment


              #7
              so does that mean I can call other created variables from other files that are created in the Initialize() function?

              and if so....how about if say.. I created a variable "testXX=3" in one file and "testXX=2" in another file... if I decided to Print (testXX) in new file...which will it print?


              Originally posted by NinjaTrader_Ray View Post
              Yes, this is expected. When you open the strategy dialog, Initialize() is called for all strategies in the dialogue. If you have a Print() statement in there, it will execute.

              The strategy to you select to run will still run of course.

              Comment


                #8
                No, you can not do that.
                RayNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                558 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                324 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                545 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                547 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X