PDA

View Full Version : duplicating code question


z32000
11-29-2007, 09:34 AM
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

NinjaTrader_Ray
11-29-2007, 09:40 AM
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...

z32000
11-29-2007, 09:49 AM
just gave that a try..

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

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...

NinjaTrader_Ray
11-29-2007, 10:00 AM
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.

z32000
11-29-2007, 10:30 AM
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?

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.

NinjaTrader_Ray
11-29-2007, 10:57 AM
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.

z32000
11-29-2007, 11:23 AM
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?


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.

NinjaTrader_Ray
11-29-2007, 11:53 AM
No, you can not do that.