Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using System.IO to write BarsArray[0] data to a text file

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

    Using System.IO to write BarsArray[0] data to a text file

    Hi Ninja Team,

    I don't know if this is simple or difficult, so here you go;

    I would like to write the date, time, and OHLC data available in BarsArray[0] to a text file from a strategy.

    For example, if I run a strategy on ES 03-10, 5 minute chart, 10 days loaded, the strategy would write 10 days of 5 min OHLC data with timestamps to a text file. It does not need to append the data.

    My endgame is to use that data in Excel, Matlab, etc. The flexability of using BarsArray[0] data over raw tick data export would be very handy.

    I've looked at the SampleFileReadWrite code but hit a wall once I need anything earlier than bar[0] "days loaded" bars back.

    Can you offer any tips or suggestions?

    EDIT: Attached NT7 strat outputs what I want to the Output Window it seems. Next step is to get it to write to a file. Is there a better way to do this?

    Thanks!
    Attached Files
    Last edited by MXASJ; 01-28-2010, 09:58 PM.

    #2
    MXASJ, I would suggest you look into the StreamWriter sample for this task.

    Comment


      #3
      Thanks Bertrand,

      Attached where I am with this (DataWriter) and with the code you mention (DataWriter2). The console output that shows up in the first one is what I want to write to disk. With the code you pointed me to I'm back to a single bar in both the console and the text file.

      I recognize this might be more C# than Ninja... but I want to write that console data to a file.

      Thanks!
      Attached Files

      Comment


        #4
        Sorry do not follow you, when I load the SampleStreamWriter indicator, I get the loaded chart data as txt file output to MyDocuments > NinjaTrader 6.5 -> isnt this what you're after?

        Comment


          #5
          My bad! I'll have a play with that code now. Thanks!

          EDIT: Added attached indictor ExportChartData, which writes Date, Time, OHLC, and volume data to a specified text file with a specified data separator in case anyone is interested.

          I might later try to offer the option of separating date and time.
          Attached Files
          Last edited by MXASJ; 01-29-2010, 10:55 PM.

          Comment


            #6
            Thanks!

            Originally posted by MXASJ View Post
            My bad! I'll have a play with that code now. Thanks!

            EDIT: Added attached indictor ExportChartData, which writes Date, Time, OHLC, and volume data to a specified text file with a specified data separator in case anyone is interested.

            I might later try to offer the option of separating date and time.
            Thanks for the indicator - it was just what I was looking for. I had to modify for 6.5, but that wasn't too bad.

            Comment


              #7
              Glad it helped, huracan. Attached v1.1, which cleans up the code, adds the ability to split date and time into separate columns, and shows the future development roadmap (in public variables) for outputing custom DateTime and having the option to output column names in the first row.
              Attached Files

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              633 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              364 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              105 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              567 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              568 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X