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

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 judysamnt7, 03-13-2023, 09:11 AM
                4 responses
                59 views
                0 likes
                Last Post DynamicTest  
                Started by ScottWalsh, Today, 06:52 PM
                4 responses
                36 views
                0 likes
                Last Post ScottWalsh  
                Started by olisav57, Today, 07:39 PM
                0 responses
                7 views
                0 likes
                Last Post olisav57  
                Started by trilliantrader, Today, 03:01 PM
                2 responses
                21 views
                0 likes
                Last Post helpwanted  
                Started by cre8able, Today, 07:24 PM
                0 responses
                10 views
                0 likes
                Last Post cre8able  
                Working...
                X