• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

data export script for NT?

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

    data export script for NT?

    I am trying to build a simple NinjaScript that will export, compile & update a Daily interval that would be written to a .txt or .csv file.



    An example scenario:

    1. I boot up NinjaTrader & connect to my Daily data provider.

    2. I select the ES future & the data populates the Daily chart.

    3. The NinjaScript (applied to the active chart) will update (write to) the ES Daily data file located on the C: drive.

    The file could then be used to supply historical Daily data; e.g. could be used the import this historical data back into NinjaTrader (if it were currently offline).

    I realize one can use the export feature but I really don’t want to do this for every market – everyday.

    Are there any examples of this item? (I haven’t been able to locate any here on the forum).

    Thanks in advance for your help!

    #2
    Hello,

    Thank you for your first forum post!

    Please see the following reference samples that deal with writing txt to a file and reading txt to a file.

    http://www.ninjatrader-support2.com/...ead.php?t=3475

    http://www.ninjatrader-support2.com/...ead.php?t=3476

    Also, here is the format that txt files need to be in to be reimported into NinjaTrader using the NinjaTraders historical data import function.

    http://www.ninjatrader.com/support/h...de.html?Import

    Let me know if I can be of further assistance.


    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      Attached is a NT7 Strategy I use all the time for exporting data for off line analysis in other programs. I built it as a Strategy so you can apply it to a basket of instruments without having to open up a bunch of charts.

      Hope it helps!
      Attached Files

      Comment


        #4
        hey MXASJ! works great! Thank you for sharing this script!

        Comment


          #5
          Thanks for sharing MXASJ!
          BrettNinjaTrader Product Management

          Comment


            #6
            hey guys!

            I have a quick question about the script -


            I was trying to export EOD Daily data but I still get this "2:00:00 PM" time being written to the output file.

            6/11/2009 2:00:00 PM,40.88,43,40.84,42.33,5000400
            6/12/2009 2:00:00 PM,41.75,41.88,41.17,41.72,3882400
            6/15/2009 2:00:00 PM,41.11,41.11,39.8,40.34,3159900
            ...etc...


            How can I change the script so that I only output the date MM/DD/YYYY - not the time.

            (I already tried changing my PC clock to show time in 24HR format). I seem unable to figure out how to adjust the script to just output the date.


            Thanks again for your help

            Comment


              #7
              Hello,

              To take the time out of the exported file then take the following section out of the script that I have highlighted in the image.

              I look forward to assisting you further.
              Attached Files
              BrettNinjaTrader Product Management

              Comment


                #8
                hello Brett - I tried to delete the item you highlighted but then I went to compile & it didn't work (attached error msg in screenshot).

                Note: I still want the calendar date (MM/DD/YYYY) - just not the time of day since I am exporting Daily data only.

                any help would b greatly appreciated!
                Attached Files

                Comment


                  #9
                  Hello,

                  Ah yes this highlighted would remove the entire time and date.

                  You would need to do some Time Manipulation to get just the date.

                  http://www.ninjatrader.com/support/h...ide.html?ToDay

                  Replacing Time[0] with ToDay(Time[0]) should do the trick.

                  For the compile error did you use the save as feature to duplicate the file or did you duplicate the file manually as each indicator/strategy needs to have a unique name.

                  Let me know if I can be of further assistance.
                  BrettNinjaTrader Product Management

                  Comment


                    #10
                    Done! Got it working - thanks guys!

                    Comment


                      #11
                      I was curious about something MXASJ mentioned before about applying the strategy to a basket of instruments.

                      How can this be done?


                      thank u

                      Comment


                        #12
                        Hello Plusticbud,

                        You can backtest against a group of stocks through the strategy analyzer.

                        Click File > New > Strategy Analyzer

                        Right click on a an instrument list and select Backtest.

                        See here for instructions on creating an instrument list.
                        Ryan MNinjaTrader Customer Service

                        Comment


                          #13
                          Cool - i will check that out. Thanks Ryan!

                          Comment


                            #14
                            plusticbid you might want to try this instead:

                            Strategies tab>New Strategy
                            Select ExportData in the drop-down Strategy field.
                            Select an Instrument List in the Instruments field.
                            Change other fields as necessary

                            That will populate your Strategies tab with all the Instruments in your Instrument list (the S&P500, for example).

                            Use Shift+arrow to select all the instruments, right click, Enable.
                            Once data has finished loading (check the lower right hand corner of Control Center), Disable and Remove all the strategies as appropriate (again through a right click).

                            Hope that helps!

                            FWIW If you look at the code you will see I have a bit of a roadmap in there for future enhancements (enums for date format output, for example). It does what I need it to do as-is but if anyone wants to step up to make it more functional that would be great.

                            Happy trading!

                            Comment


                              #15
                              hello again MXASJ!

                              I followed your instructions & it worked great!!

                              Thank you once again for your help -

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Johnny, Today, 11:42 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post Johnny
                              by Johnny
                               
                              Started by habibalex, Today, 09:03 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post sledge
                              by sledge
                               
                              Started by ptpatrader, Today, 11:38 AM
                              2 responses
                              14 views
                              0 likes
                              Last Post ptpatrader  
                              Started by emuns, Today, 11:20 AM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_Jim  
                              Started by chartish, Today, 10:33 AM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_PatrickG  
                              Working...
                              X