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 tsantospinto, 04-12-2024, 07:04 PM
                7 responses
                126 views
                0 likes
                Last Post aligator  
                Started by futtrader, 04-21-2024, 01:50 AM
                5 responses
                56 views
                0 likes
                Last Post NinjaTrader_Eduardo  
                Started by PeakTry, Today, 10:49 AM
                0 responses
                2 views
                0 likes
                Last Post PeakTry
                by PeakTry
                 
                Started by llanqui, Today, 10:32 AM
                0 responses
                5 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by StockTrader88, 03-06-2021, 08:58 AM
                45 responses
                3,994 views
                3 likes
                Last Post johntraderuser2  
                Working...
                X