Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Import Data Through AddOn

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

    Import Data Through AddOn

    Hi,

    Is it possible to import data from an external file through an AddOn and save within NinjaTrader?

    This is to automate the import process rather than using the import historical data window.

    Thanks

    #2
    Hello tmfdouglas,

    Thank you for writing in.

    I am looking further into this, but can you please clarify what you mean by automating the import process? Are you wanting to import multiple data files at one time?

    When importing through the Historical Data window, you can select multiple files at once upon clicking the Import button in the Load window.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      So for example say I wanted to be able to place files containing data in a folder and have this data automatically imported. I could either check the folder periodically or use a file watcher, what I'd need though is the ability within an add-on to import that data without having to go through the import data window.

      Thanks

      Comment


        #4
        Hello tmfdouglas,

        Thank you for that additional clarification. I'm looking further into this for you and will provide additional details with my findings.
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Hello tmfdouglas,

          Thank you for your patience on this.

          It is, indeed, possible to import historical data through an AddOn.

          What you'll need to do is create a new instance of the TextImportType class. You'll need to modify the class, however, as it'll bring up a window to choose files to import, but here's an example of how you can call this from an AddOn:

          Code:
          ImportTypes.TextImportType textImportType = new ImportTypes.TextImportType();
          textImportType.SetState(State.Configure);
          if (textImportType.State == State.Terminated)
               return;
          
          // assuming last data timestamped in UTC
          textImportType.Import(MarketDataType.Last, TimeZoneInfo.Utc, true, true, null);
          Here's an example of how you can implement the FileSystemWatcher class to check if new files are added/modified to the folder you wish to import from: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

          The source code for TestImportType can be found within the ImportTypes folder in the NinjaScript Editor. I'd suggest making a copy of the ImportType to modify. Ensure you're calling the copy rather than the original.
          Zachary G.NinjaTrader Customer Service

          Comment


            #6
            Thanks Zachary, this is exactly what I was looking for. Will run some tests and reply back if any issues.

            Comment


              #7
              Hi,

              The code you provided worked well, thanks.

              Is there a way to import the last, bid and ask at the same time though, I'm having to run three separate imports using

              textImportType.Import(MarketDataType.Last, TimeZoneInfo.Utc, true, true, null);
              textImportType.Import(MarketDataType.Ask, TimeZoneInfo.Utc, true, true, null);
              textImportType.Import(MarketDataType.Bid, TimeZoneInfo.Utc, true, true, null);

              but the code within TextImportType seems to support loading ask, bid and last at the same time?

              Thanks

              Comment


                #8
                Hello tmfdouglas,

                Thank you for your response.

                The ImportType conforms to the Import options available under Tools > Import > Historical Data. So you can only import one data type at a time. Refer to the file and data formats information at the following link: http://ninjatrader.com/support/helpG.../importing.htm

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by pibrew, Today, 06:37 AM
                0 responses
                0 views
                0 likes
                Last Post pibrew
                by pibrew
                 
                Started by rbeckmann05, Yesterday, 06:48 PM
                1 response
                12 views
                0 likes
                Last Post bltdavid  
                Started by llanqui, Today, 03:53 AM
                0 responses
                6 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by burtoninlondon, Today, 12:38 AM
                0 responses
                10 views
                0 likes
                Last Post burtoninlondon  
                Started by AaronKoRn, Yesterday, 09:49 PM
                0 responses
                15 views
                0 likes
                Last Post AaronKoRn  
                Working...
                X