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

UserDataDir location?

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

    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"

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

    Comment


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

      Comment


        #4
        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?

        Comment


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

          Comment


            #6
            Burga1,

            I suggest you just print the file path directly and see what it is evaluating to.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Thank you, what is the correct format to print the directory path? The following is throwing an error: Print(dir.ToString());

              Comment


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

                Print(path);
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  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"...

                  Comment


                    #10
                    Please provide complete simple-as-possible code. Thank you.
                    Josh P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by helpwanted, Today, 03:06 AM
                    1 response
                    7 views
                    0 likes
                    Last Post sarafuenonly123  
                    Started by Brevo, Today, 01:45 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post Brevo
                    by Brevo
                     
                    Started by aussugardefender, Today, 01:07 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post aussugardefender  
                    Started by pvincent, 06-23-2022, 12:53 PM
                    14 responses
                    242 views
                    0 likes
                    Last Post Nyman
                    by Nyman
                     
                    Started by TraderG23, 12-08-2023, 07:56 AM
                    9 responses
                    385 views
                    1 like
                    Last Post Gavini
                    by Gavini
                     
                    Working...
                    X