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

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.





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



    Let me know if I can be of further assistance.


    Let me know if I can be of further assistance.

    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!

          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

              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.



                  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.

                  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 M.NinjaTrader 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 bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,602 views
                              0 likes
                              Last Post aligator  
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              18 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              12 views
                              0 likes
                              Last Post Javierw.ok  
                              Working...
                              X