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 algospoke, 04-17-2024, 06:40 PM
                6 responses
                48 views
                0 likes
                Last Post algospoke  
                Started by arvidvanstaey, Today, 02:19 PM
                4 responses
                11 views
                0 likes
                Last Post arvidvanstaey  
                Started by samish18, 04-17-2024, 08:57 AM
                16 responses
                61 views
                0 likes
                Last Post samish18  
                Started by jordanq2, Today, 03:10 PM
                2 responses
                9 views
                0 likes
                Last Post jordanq2  
                Started by traderqz, Today, 12:06 AM
                10 responses
                19 views
                0 likes
                Last Post traderqz  
                Working...
                X