Skip to main content

Fully Automating the Interactive Brokers plugin of AmiBroker (TWS API)


Using the Interactive Brokers (IB) plugin with AmiBroker requires a delicate touch. It's not that it doesn't work, it's that the current instructions are old and miss highly important points to achieve full automation of downloading multiple symbols.

This document will identify the method to automate AmiBroker 5.30 on Windows XP(*) to fill ~180+ days of historical 1-minute data for up to 100 symbols using the AmiBroker IB plugin to connect to the Interactive Brokers, Trader Workstation's API.

Not all symbols will fully update. The primary issue seems to be the occasional symbol will not download the latest month of data.

At the step that says, "Touch Nothing! until the backfill is complete," do exactly that. Any changing of symbols (and seemingly touching any other control), will interrupt the RT symbol list backfill. Switching off "automatic backfill on first data access" helps, but doesn't completely solve backfill interruptions.

This document borrows heavily from the existing AmiBroker "Interactive Brokers DATA PLUGIN" document at . Changes, modifications, and editing done here are to more fully explain the backfill automation steps. Follow the AmiBroker document while making the below changes.

As of AmiBroker 5.30, the IB plugin is included by default. Skip step 1., you do not need to download it separately.


  • Select Configure -> API -> Enable Active X and Socket clients
  • Select Configure -> API -> All API Settings...
      In "Trusted IP addresses," click "Create" and enter

Optionally create an IB Paper Trading account. Instructions are at : . I would recommend this, as then you no capability of accidentally executing live orders.

In AmiBroker
Follow the instructions from step 4. "Run AmiBroker and create new database with Interactive Brokers plugin as a data source, following these steps:"

Change these values

  • Enter 400000 into "Number of bars to load" field
      (This is approximately 3 years of 1-minute data, and will allow room for future accumulation.)

Then move down to , follow the instructions, and,

  • Switch off "automatic backfill on first data access" (Uncheck)
  • Click 'Ok' twice to save everything.

To get full automation, you need to populate the Real Time quote window. There are several ways to do this, here is one method.

In AmiBroker

  • Select View -> Realtime Quote
  • Prepare a comma separated list of symbols you are interested in (**)
  • Right Click on the Realtime Quote window, select Type-in Symbol(s)
  • Paste in your list of symbols

The rest of the BACKFILL instructions are interesting and explain the location of where to click. To start the automated downloading, you need to do these five steps as well :

  • Right Click on the "CONN" area
  • Select Backfill length -> 180 days
  • Right Click on the "CONN" area
  • Select "Backfill All RT quote window symbols"
  • Touch Nothing! until the backfill is complete

The tooltip pop-up messages Backfill timed-out..., pacing violation, downloading n/nn, etc. are normal. When the pop-ups stop you should be finished. Mouse Hover over the "CONN" area for your status.

Optional: Create a 'working' Database (Backup Procedures)
I managed to somehow wipe my working database, either through ingnorance or by running a piece of our of spec example code. Not sure which, but I was sure glad I had made a backup of my primary IB database. There are more ways to making backups than there are ways to skin a cat, so use whatever you're comfortable with. Here's my general procedure for such...

Once Backfilling is finished:

  • In AmiBroker, Click File -> Save Database
  • Close AmiBroker
  • Open Windows Explorer (or whatever you use for file management)
  • Find the IB database (C:\Program Files\AmiBroker\IB)
  • Copy the entire IB directory to somewhere else (C:\backups\IB)
  • Copy the Backup (C:\backups\IB) to a make a Working database (C:\Program Files\AmiBroker\IBWorking)
  • Open AmiBroker
  • In AmiBroker, Click File -> Open Database
  • Select the Working database (C:\Program Files\AmiBroker\IBWorking)
  • Click File -> Database settings...
      and change "Data source:" to "(local database)"
  • Click File -> Save Database

You can now be reasonably assured no matter what you do that your master IB database won't be corrupted.

When you want to add more bars to your IB database, close your working database and reopen your IB database and follow the "five steps" above. AB will chug away downloading and once done, re-follow the "Backup Procedures," switch back to your working database and you're all set...



* Should also work on Vista, Win 7, Win 2000, Win NT, Win98 as well, but I've not tested it.

** Example of all current 3x ETFs:

References :


Interactive Brokers
The table listing "Valid Duration and Bar Size Settings for Historical Data Requests" in the above link, seems incorrect. You can get ~180+ days of historical 1 minute data, it just takes a long time.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi Michael,Thanks for the

Hi Michael,
Thanks for the instructions, I just have a question about the optional step: Create a 'working' Database, since we have already saved the external database from IB, so can we use this external database as a working database, rather than using a local database.
Cheers, Fan