Timeframes, Ticks and How Bars Are Built
The previous lesson showed that a bar discards information. This one shows where the discarding happens, how much of it is a choice you make, and why one of those choices — the base time interval of a database — is far harder to reverse than it looks in the dialog box.
The raw material: trade prints
Section titled “The raw material: trade prints”Underneath every chart is a stream of individual trades. Each one carries a timestamp, a price, a size, and usually an exchange identifier and one or more condition codes saying what kind of trade it was: a regular sale, an auction print, an odd lot, a trade reported late, a trade agreed away from the exchange.
Those condition codes matter more than beginners expect. Whether a particular print is allowed to set the day’s high, or to count toward volume, or to be the official close, is a decision made by whoever built your data — and different vendors make it differently. This is one reason two feeds can show different highs for the same session and both be defensible.
From trade to chart
- Trades at the exchangeTimestamp, price, size, condition codescomplete
- Vendor’s tick streamFiltered and normalised by vendor rulesfirst losses
- Base-interval bars in your databaseThe finest grain you will ever have
- Compressed bars5-minute, hourly, daily, weekly — built on demandfurther losses
- Indicators and rulesEverything you compute sits on top of all of it
Time-based bars: buckets on a clock
Section titled “Time-based bars: buckets on a clock”The ordinary way to turn prints into bars is to divide the clock into equal buckets and summarise each one. A five-minute bar covers a five-minute slot; every print with a timestamp inside that slot contributes.
Two mechanical details of that bucketing decide whether your intraday analysis lines up with anyone else’s.
Which timestamp the bar wears
Section titled “Which timestamp the bar wears”A bar covering 09:00:00 to 09:29:59 could reasonably be labelled 09:00, or 09:29:59, or with the time of the first trade in it, or the time of the last. AmiBroker treats this as a preference rather than a law: Tools → Preferences → Intraday offers exactly those four options for “Time compressed bars show” — time of the first tick inside the bar, time of the last tick inside the bar, start time of the interval, or end time of the interval.
The setting changes no prices at all. It changes which label each set of prices is filed under, which is enough to shift every one of your intraday comparisons by one bar if you and your data source disagree about it.
Where the buckets start
Section titled “Where the buckets start”By default, minute buckets are anchored to the clock, so a 45-minute interval on a market that opens at 09:30 produces bars beginning at 09:00, 09:45, 10:30 and so on — with the first bar of the session truncated. The same Preferences page offers Align custom minute bars to regular market hours, which trims the pre-market portion so that a new bar begins exactly when trading hours start: 09:30, 10:15, 11:00.
Neither behaviour is wrong. But an “opening range” measured on clock-anchored bars is a different quantity from one measured on session-anchored bars, and nothing in the chart tells you which you are looking at.
Compression: building a bigger bar from smaller ones
Section titled “Compression: building a bigger bar from smaller ones”Once bars exist at some interval, larger intervals are produced by compressing them. The rule is the same one used to build a bar from trades, applied one level up: the open of the compressed bar is the open of the first sub-bar, the close is the close of the last, the high and low are the extremes, and volume is the sum.
AmiBroker names these rules explicitly in its timeframe functions —
compressOpen, compressHigh, compressLow, compressLast and compressVolume are the
documented modes of TimeFrameCompress(). Seeing them written down is useful, because it
makes clear that compression is arithmetic, not interpretation.
Five 1-minute bars compressed into one 5-minute bar (synthetic)
| Bar | 09:30 | 09:31 | 09:32 | 09:33 | 09:34 | → 09:30 (5-min) |
|---|---|---|---|---|---|---|
Open | 50.10 | 50.22 | 50.31 | 50.18 | 50.25 | 50.10 |
High | 50.28 | 50.35 | 50.33 | 50.27 | 50.44 | 50.44 |
Low | 50.08 | 50.19 | 50.14 | 50.12 | 50.21 | 50.08 |
Close | 50.22 | 50.31 | 50.18 | 50.25 | 50.41 | 50.41 |
Volume | 12,400 | 8,900 | 15,200 | 7,600 | 21,300 | 65,400 |
Look at what the compressed bar cannot say. Three of the five minutes closed lower than they opened; the five-minute bar shows a clean advance. The 09:32 minute made a lower low than 09:31 after making a lower high — a small structural event, entirely invisible one level up. Every compression step erases structure at the level below it.
Daily bars are not a special case
Section titled “Daily bars are not a special case”It is tempting to think of daily data as the natural unit and intraday as a subdivision of it. Mechanically, it is the other way round: a daily bar is just another compression, and its boundaries have to be defined by someone.
In AmiBroker those definitions live in File → Database Settings → Intraday settings, and they are per-database. Two of them change what a daily bar contains:
- Filtering decides which intraday data is displayed at all: 24 hours with no filtering, day session only, night session only, or day and night sessions only. Trading hours for each session are entered in your local time zone, with a separate time-shift value for the difference between your clock and the exchange’s.
- Daily time-compression uses decides which clock defines a day when intraday bars are compressed to daily: exchange time, local time, or the day and night session times as defined above.
Change either and the daily bars change, from the same underlying prints. A rule that triggers on the daily close is therefore sensitive to a setting most users never open.
Sessions, exchange time and daylight saving get a whole part of their own later in the course. For now, treat “what counts as a day” as a configured answer rather than an obvious one.
The intervals AmiBroker offers
Section titled “The intervals AmiBroker offers”The built-in chart intervals are daily, weekly, monthly, hourly, 15-minute, 5-minute and 1-minute, plus 15-second, 5-second and tick for real-time intraday work. On top of those you can define five custom N-minute intervals and five custom N-tick intervals in Tools → Preferences → Intraday; custom intervals appear only in the View → Intraday menu.
N-tick bars are worth a moment because they are the clearest example of a bar that is not
a clock bucket at all. A 133-tick bar closes after 133 prints, whenever that happens to
be — fast in a busy minute, slow in a quiet hour. It equalises activity instead of time.
AFL can address them with TimeFrameSet() given a negative interval, and the guide is
explicit that this works only if the database’s base time interval is tick.
The base time interval: the decision you make once
Section titled “The base time interval: the decision you make once”Every AmiBroker database has a base time interval, set in File → Database Settings. It defines the finest grain the database stores. Everything coarser is produced by compression on the fly; nothing finer is ever available.
Three consequences follow directly:
- An end-of-day database can never show intraday charts. The guide says so from both directions: intraday charting and analysis are unavailable until the base interval is set below end-of-day, and on the charting side, intraday intervals are disabled when the database is in end-of-day mode.
- The base interval sets a floor, and every interval at or above it becomes available. Set it to 5-minute and all periodicities from 5-minute up are enabled. Set it to 1-minute and you additionally get 1-minute, at a cost described below.
- Changing the setting later does not give you finer history. This is the part that catches people, so it is worth being precise about what the documentation does and does not say.
The guide’s own recommended workaround for wanting both long daily histories and intraday detail is to run two databases — one end-of-day, one intraday — and, where the data plugin supports it, the Allow mixed EOD/Intraday data option, which lets a single database hold both kinds of bar.
Why not simply store everything at tick resolution?
Section titled “Why not simply store everything at tick resolution?”Because bars cost memory, and the arithmetic is unforgiving. AmiBroker’s performance documentation states that one data bar occupies 40 bytes. A hundred thousand bars is therefore about 4 MB per symbol, actually allocated, and the guide advises against going beyond roughly 100,000 bars per symbol when working with a 4 MB CPU cache. The Database Settings dialog shows the equivalent number of days next to the bar count for your chosen interval, which is the number worth reading before you accept a value.
A 500-symbol universe at 100,000 one-minute bars each is not a configuration problem; it is a machine specification. The base-interval choice is therefore a genuine trade-off between history, granularity and hardware — which is exactly why it deserves to be made deliberately rather than by accepting a default.
A decision procedure
Section titled “A decision procedure”Ask, in this order:
- What is the shortest holding period I want to be able to study? If the answer is days or longer, an end-of-day database is not a compromise — it is the right tool, and it will hold decades of history on any machine.
- Do I need to see inside the day at all? If yes, what is the coarsest intraday interval that would answer the question? Choose that as the base interval, not the finest one available.
- How much history do I need at that grain, and can I afford it? Multiply bars per symbol by symbols by 40 bytes and look at the result before committing.
- Am I willing to rebuild if I am wrong? If not, err one step finer than you think you need — but only one, and only if the memory arithmetic allows it.
Part 19 walks through this again with an intraday database in front of you. Deciding it now is cheaper than deciding it in six months with a database full of data.
Bars are built by bucketing trades, and every level of bucketing throws away the structure below it. The timestamp a bar carries and the point at which buckets start are configurable and worth checking. Daily bars are compressions like any other, and what counts as a day is defined by per-database session settings. Compression runs in one direction only, which makes the base time interval of a database a decision that is expensive to revisit — not because a control is locked, but because the information was never stored.
The next lesson takes a different kind of loss: not detail discarded by compression, but prices deliberately rewritten by corporate actions.
Check your understanding
Sources for this lesson
5 verified · checked 2026-08-31
- 01AmiBroker User's Guide — Database settings§ Base time intervalamibroker.com/guide/w_dbsettings.html2026-08-31
- 02AmiBroker User's Guide — Charting§ Changing bar interval (periodicity)amibroker.com/guide/h_charting.html2026-08-31
- 03AmiBroker User's Guide — Preferences§ Intraday tabamibroker.com/guide/w_preferences.html2026-08-31
- 04AmiBroker User's Guide — Multiple Time Frame Supportamibroker.com/guide/h_timeframe.html2026-08-31
- 05AmiBroker User's Guide — Performance tuningamibroker.com/guide/x_performance.html2026-08-31
Every technical claim on this page was checked against the official AmiBroker documentation on the date shown. Where the course disagrees with folklore, the source is how you can tell which one to trust.