Populate Amibroker with 5 years Interactive-Brokers history data

The maximum history data i can get when connecting to Interactive Brokers is 180 days.

is it possible ( with the help of Interactive Broker-API and AFL ) to get all the available data to feed my Amibroker ?

anyone succeed doing this ?

As you wrote, regular maximum at Interactive Brokers is 180 days1) (less than a year, not 5 years). And it can be retrieved as described in manual
by right click on plugin status:


1) 5 years backfill is only available when you do $10000 per month in commissions, but then using true tick-by-tick feed like IQFeed is really recommended and costs a very small fraction of it.



I'm connecting to IB but can only seem to get a maximum of 3 days worth of data. Even though I follow the instructions and right click on backfill length and select say 30 days, I still only get 3 days. It doesn't matter whether I select 1, 5, 15 minute or daily candles, it only gives 3 days.

Appreciate if you could assist.


1 Like


  • Number of bars to load - defines how many bars should be loaded from external data source and kept in AmiBroker. Examples: 10-years EOD: 2600, 60-days intraday 1-minute: 30000 (approx). This setting has no effect if data source is set to (local).
  • Base time interval - defines what 'base' bar interval is used in this database. For real-time data sources this should be set once at the database creation time. This is so because real-time sources need to collect RT ticks and pack them (time-compress) into interval bars. This setting defines the minimum 'grain'. For EOD sources it is (End-of-day (daily). For real-time sources this should be 1-minute or higher. For some real-time sources (like eSignal) this can be also set to tick, 5-sec or 15-sec.
    Please note also that you won't be able to use intraday charting and/or analysis until base time interval is set to something below end-of-day interval (it can be 1-minute for example). For more details please read Tutorial: Basic charting guide.

Hello travick,
The same happens to me.
@Tomasz, Could you correct it? How?
I have LATEST version of TWS and Amibroker 6.00.2. Both in x64.
I tried in (x32, x64), and Windows (7, 10)
Backfill length: 180
And only 18 candles.


Hi Alexis913,
Were you able to find a solution? I'm new to Amibroker and using TWS as well, I'm running into the same issue.

Cancel that - for the benefit of others who may run into same issue.

Tomasz addresses it in post above dated Dec '17 by right-clicking on the Plugin Status green 'CONN' on the bottom right hand corner and adjusting. I presumed the date adjustment was accessible from the Database settings window as well.

I still do not get how to backfill.

There are 3 bars filled. The backfill length is set to 180 days. When I click to the green bar and choose "Backfill current", it turns teal for an instant and back to green again.

There is a line in the document AmiBroker - IB real time feed :

Note that backfill is in bar interval of 1-minute or less (TWS limitation).

I do not quite understand what it means. Does it mean that it is not possible to backfill for instance hourly data?


Go to File->Database Settings and make sure you have "Number of bars" large enough to accommodate 180 days * 24 hours per day * 60 minutes in an hour. That is 259200 bars

Did not help.

I am a bit confused about those settings, too.

  1. Do I really have to set the base time interval to 1 minute to backfill? Cannot it be higher like 1 hour?
  2. If I specify 1 minute instead of 1 hour and 259200, the dialog tells me "approx 2 years". I have set the "Show day session only" in the Intraday settings but it does not seem to infulence the calculation of the time period. I am unsure how it is calculated as 180 * 24 * 60 = 259200 as you wrote.

How to backfill day session hourly data for 180 days?

If I create a database today and want to populate it with historical data of past 180 days, is it backfilling at all?

Alternatively, I could just download the historical data with a Python interface I used some time ago and import it to the AB database, I suppose. But I would be happier to do it in the AB way.

Number of bars depends on both time span (number of days you want to get) AND bar interval.

Use this:


I created a brand new database with the following settings:

Added AAPL and set backfill size to 180 days.

Chose "Backfill current" from the green bar. It instantly went teal, then back to green as described above. The chart area remains black and the Price indicator says "Not enough data available but there are only 2 bars in AAPL".

However, if i move the mouse cursor over the black area, the tooltip shows some prices (definitely more than 2). I have no idea how that comes.


Not sure IB supports 1h. Did you try 1 minute like Tomasz said?

I would assume the available data points from looking at Amibroker instructions are second, minute and daily.

IB surely supports 1 hour: TWS API v9.72+: Historical Bar Data

Yes, I tried 1 minute without much success either. Will retry tomorrow.

You should use 1-minute base interval as mentioned earlier. This allows to access ANY other N-minute interval (including hourly) in AmIBroker because AmiBroker would compress data on the fly.

Thanks, it worked that way!



Well in my experience with compressing 5min (or 1min does not matter) bars to hourly bars, there may be complications. For instance if you are trading two stocks with different 5min bars as their data because they belong to different exchanges, when you compress this into hourly bars, AB may provide you two separate hourly bars in CBT because intervals compressed are not identical.

Therefore, to mitigate this I trade 1 hourly bars with 1 hourly data and do not compress 1min/5min into hourly bars.

Of course this is a non-issue if your portfolio of stocks are all from same exchange say S&P500 so they have the exact intraday bars to be compressed into 1 hourly bars.

Just something to note while trading a diverse portfolio and compressing 1min bars to hourly.

Many thanks,

If you have data holes/misalignment you should simply use "Pad and align" option in Analysis. Also you have to use correct settings in Tools->Preferences, "Intraday", Time stamp of compressed bars shows: START time of interval That is default and highly recommended setting (don't change it).

Manual backfill (clicking on the symbol and waiting for backfill) succeeds but I am having trouble with bulk backfill.

I added a csv list of symbols to the the same database I used with the successful experiment with AAPL above and to the RT quote window and clicked "Backfill All RT quote window symbols". It started backfilling them one by one and I went outside. After return I discovered that none of the symbols presumably backfilled had any bars. If I clik to the symbol in the Symbols window, the Chart tells me that "Not enough data available", etc.

Is it possible to log that process? I would like to see log lines like "AAPL backfill finished OK Aug 13 2021 3:00 pm, 259200 bars filled" or something similar to pin down what should be present and what not.

84 symbols backfilled so far during the next try. I sincerely hope that my previous post is an user error.