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

Exporting Data using a particular DATE format

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

    Exporting Data using a particular DATE format

    I am hoping some generous soul can help me here. I am not an astute programmer, but would like to take a shot at this.

    I would like to export the data from NT (by applying an indicator on a bar chart) that writes basic bar data to a csv file. I have looked at the example in StreamWriter, but my need is a special format of the Date and Time.

    I want to export the Date, Time field as ONE and in any format that Microsoft supports (Julian etc ...). Just that the requirement is that it is one field...

    So for example..

    <Microsoft Compatible Date+Time>, Open, High, Low, Close

    Yes, the chart is intraday.

    Thank you ahead of the help

    #2
    Hello sardana,

    Thank you for your post.

    You could use DateTime.Now:
    Code:
    sw.WriteLine(DateTime.Now + " " + Open[0] + " " + High[0] + " " + Low[0] + " " + Close[0]);

    Comment


      #3
      Thanx Patrick. Perhaps I was unclear... The DateTime.Now will just print a CONSTANT date time (though the format might be what I am looking for), but it needs the DateTime of the BAR, not the system time

      Thanx

      Comment


        #4
        Originally posted by NinjaTrader_PatrickH View Post
        Hello sardana,

        Thank you for your post.

        You could use DateTime.Now:
        Code:
        sw.WriteLine(DateTime.Now + " " + Open[0] + " " + High[0] + " " + Low[0] + " " + Close[0]);
        Patrick,
        How do I get MM/DD/YY as output of Date. I used the following -

        ToDay(Time[0]).ToString("d")

        and it still prints YYYYMMDD !!

        Can you/someone here help what might I be doing wrong here?

        Thanx

        Comment


          #5
          Hello sardana,

          Thank you for your response. MM/DD/YY

          For this we can use .Month, .Day, and .Year with the Time[0] data series:
          Code:
          sw.WriteLine(Time[0].Month + " " + Time[0].Day + " " + Time[0].Year + " " + Open[0] + " " + High[0] + " " + Low[0] + " " + Close[0]);

          Comment


            #6
            Time[0].ToString("dd/MM/yyyy")

            one field and will import to Excel easily enough.

            Comment


              #7
              Thanx everyone. One hurdle gone... I did take the StreamWriter example posted in this forum and can now get the data out in the right format.... However... when I apply that indicator to a chart, no matter how much data I have BEFORE 12/31/2013, the file is only starting from that date, 8:35 am... I am again confused... Can someone give me some pointers... perhaps I have some settings wrong... for example, I have 15 min data going back to June 2013, and the MaxBarBack is at the default min of 256... yet no data is written prior tho 12/31/2013 8:25am

              Thanx

              Comment


                #8
                The sample I reference in my post #7 is located here



                Thank you

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Tim-c, Today, 10:58 AM
                0 responses
                1 view
                0 likes
                Last Post Tim-c
                by Tim-c
                 
                Started by traderqz, Yesterday, 09:06 AM
                3 responses
                21 views
                0 likes
                Last Post NinjaTrader_ThomasC  
                Started by f.saeidi, Today, 10:19 AM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by kujista, Today, 06:23 AM
                5 responses
                18 views
                0 likes
                Last Post kujista
                by kujista
                 
                Started by traderqz, Today, 12:06 AM
                3 responses
                6 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X