Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Import to SQL

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

    Import to SQL

    Hello, i have a problem with the format which NinjaTrader saves the datetime.
    SQL Server does not parse the time without the ":" between the hours, minutes and seconds.

    I've been looking for a solution, but I have no luck so far.
    Please i seek assistance on this issue.

    Thank you.

    #2
    What version of NinjaTrader 8 are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.0.?.?)

    Can you elaborate on how you're running into this issue exactly? Is there any associated error message?

    Comment


      #3
      8.0.20.1 64-bit

      I don't know if i made myself clear. Just in case i will clarify.

      I exported Historical Data, now i want to import it to my SQL server. And the "yyyyMMdd HHmmss" is not valid due to the absense of the colons in the time.

      Thank you.

      Comment


        #4
        Thank you for the clarification.

        I would not expect the time stamps of exported historical data to include semicolons separating the date from the time. Here is a help guide link with more information on what to expect with NinjaTrader historical data formatting:I am not aware of any tool that would automatically populate the semicolons necessary to make importing into an SQL. This would be possible to automate via NinjaScript. Would you like more information on how to program this yourself? Otherwise, you would have to perform this edit manually.

        I also encourage other forum users who may know of an existing tool that accomplishes this export format to provide that information.

        Comment


          #5
          I didn't say semicolons. I meant the colons of the time. NT exports it as "HHmmss" instead of "HH:mm:ss", that is the problem.
          Thank you.

          Comment


            #6
            I apologize for misreading your message. In any case, NinjaTrader exports the data in the format defined in the help guide and the same answer I provided applies to any desired change from that format.

            Comment


              #7
              Code:
              List<string> readFiles = new List<string>();
                          readFiles.Add(@"C:\file.csv");
              
                          List<string> writeFiles = new List<string>();
                          writeFiles.Add(@"C:\file.2.csv");
              
                          for (int i = 0; i < readFiles.Count; ++i)
                          {
                              StreamReader reader = new StreamReader(readFiles[i]);
                              StreamWriter writer = new StreamWriter(writeFiles[i]);
                              string line;
                              while ((line = reader.ReadLine()) != null)
                              {
                                  var split = line.Split(';');
                                  if (split[0].Length > 15)
                                  {
                                      var date = DateTime.ParseExact(split[0], "yyyyMMdd HHmmss fffffff", null);
                                      split[0] = date.ToString("yyyy-MM-dd HH:mm:ss.fffffff");
                                  } else
                                  {
                                      var date = DateTime.ParseExact(split[0], "yyyyMMdd HHmmss", null);
                                      split[0] = date.ToString("yyyy-MM-dd HH:mm:ss");
                                  }
                                  writer.WriteLine(string.Join(";", split));
                              }
                              reader.Close();
                              writer.Close();
                          }

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              93 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              48 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              31 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              34 views
              0 likes
              Last Post TheRealMorford  
              Started by Mindset, 02-28-2026, 06:16 AM
              0 responses
              70 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X