NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 06-19-2009, 10:27 PM   #1
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default UserDataDir location?

Can I please get an explanation as to what file path this script causes NT to use? My understanding is that it would look for the .txt file in the NinjaTrader 6.5 directory in the "My Documents" folder...if this is incorrect please explain. I thank you in advance.

privatestring path = Cbi.Core.UserDataDir.ToString() + "MyFile.txt";

Basically I need to know if the "Cbi.Core.UserDataDir" is the NinjaTrader 6.5 folder in "My Documents"
Burga1 is offline  
Reply With Quote
Old 06-20-2009, 12:07 PM   #2
scjohn
Senior Member
 
Join Date: Dec 2004
Location: , ,
Posts: 225
Thanks: 0
Thanked 11 times in 8 posts
Default

I am running Vista and this is what I use:
dir = new DirectoryInfo(System.Environment.GetFolderPath(Env ironment.SpecialFolder.MyDocuments));
Print ("AutoNet||Constructor Path:" + dir.ToString() );

My assumption is that if you are running XP that it will also point to the correct directory.
scjohn is offline  
Reply With Quote
Old 06-21-2009, 10:28 AM   #3
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks scjohn but I get some errors I don't understand when I try your code...let me explain my problem a bit more.

I have an Indicator running on a machine using that code and it runs perfectly. I "exported" the Indicator to use on another machine running NT and now the Indicator doesn't work after I've imported. I believe the problem is because the file the Indicator "searches" for in the "NinjaTrader 6.5" folder of the "My Documents" folder is not found because the different machine has a different name...thus the path for "My Documents" is slightly different. I was trying to confirm if this is the problem or not by attempting to find out what the full path name is that NT is searching, I would have thought it just searches the "My Documents" folder regardless of machine name...
Burga1 is offline  
Reply With Quote
Old 06-22-2009, 07:27 AM   #4
scjohn
Senior Member
 
Join Date: Dec 2004
Location: , ,
Posts: 225
Thanks: 0
Thanked 11 times in 8 posts
Default

Cbi.Core.UserDataDir.ToString() will point you to the NinjaTrader 6.5 directory. Which is a sub directory located in either My Documents or Documents directory depending upon your operating system. Cbi.Core.UserDataDir will have the full path to the NinjaTrader 6.6 directory. So, yes, the full path will more than likely be slightly different on a different machine but you should still end up pointing to the NinjaTrader 6.5 directory. Unless you are modifying that path in your code it is my opinion that the code should work on both machines. It's hard to diagnose this type of problem without looking at the code. Have you check the the log files for errors?
scjohn is offline  
Reply With Quote
Old 06-22-2009, 10:30 AM   #5
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank you for the reply. Yes I looked at the log but there are no errors there. The only thing I see is in the "Output Window" whereby it reports "file does not exist" which is how it is coded to report if in fact the needed file is not found...that is why I posted originally, the file in fact does exist where it should and thus that led me to believe for some reason the path to the file was somehow being read differently on a different machine...

The code has been unmodified from its original state after being imported as well.
Burga1 is offline  
Reply With Quote
Old 06-22-2009, 10:33 AM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Burga1,

I suggest you just print the file path directly and see what it is evaluating to.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-22-2009, 10:53 AM   #7
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank you, what is the correct format to print the directory path? The following is throwing an error: Print(dir.ToString());
Burga1 is offline  
Reply With Quote
Old 06-22-2009, 10:55 AM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

You already set it to your string variable. Just print your string.

Print(path);
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-22-2009, 12:41 PM   #9
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks for the info, that worked well however just leads to a deeper mystery...the path being printed is exactly as it should be. The file is where it should be (in that path), so I now have no clue why the script reports "file does not exist"...
Burga1 is offline  
Reply With Quote
Old 06-22-2009, 01:28 PM   #10
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Please provide complete simple-as-possible code. Thank you.
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
TickCounter text location ssg10 Indicator Development 4 02-10-2009 01:53 AM
Programm NT for Chart Location? ajtrader General Programming 3 07-29-2008 06:20 AM
Automated Strategy Performance/Co-Location nolantx Automated Trading 3 06-03-2008 10:15 PM
Physical location of strategies? adrian Miscellaneous Support 2 04-13-2008 05:27 PM
Any change to dll location? Folls Strategy Development 2 01-28-2008 04:56 PM


All times are GMT -6. The time now is 03:06 AM.