Quant Memo
Foundational

How an OHLC Bar Is Actually Built

Open, High, Low, Close bars look like a simple summary of a time period, but the exact rules for which trades count, how the open and close are chosen, and how bars handle gaps in trading vary enough to change backtest results.

Prerequisites: The Trading Day Boundary and Session Timestamps

An OHLC bar — open, high, low, close — looks like the simplest possible summary of price action over some interval, and mechanically it is: four numbers taken from the trades that occurred in that window. But "which trades occurred in that window" and "which trade counts as the open or close" hide several conventions that differ across data vendors and asset classes, and they change the bar you get.

The choices hiding inside a bar

Which trades count. Does the bar include only regular-session trades, or does it also fold in pre-market and after-hours prints? Does it include odd-lot trades, or only round-lot trades? Different vendors make different defaults here, and two "1-minute bars" for the same stock from two providers can genuinely disagree if one filters odd lots and the other doesn't.

What counts as open and close. For a stock, the "open" of a daily bar is ideally the official opening auction price, not simply the first trade timestamp after 9:30 — a stray odd-lot trade printed a second after the open shouldn't override the auction. Similarly the "close" should be the official closing auction price, not the last raw trade of the day, which as covered in closing-benchmark conventions can differ from a naive "last timestamp" extraction.

How gaps are handled. If no trade occurs during a bar's interval — common for illiquid instruments on a 1-minute bar — some systems simply omit the bar entirely, some forward-fill the previous close as a flat O=H=L=C bar, and some emit a bar with null values. These produce visibly different-looking charts and, more importantly, different backtest fill assumptions for strategies that check "did price touch this level" bar by bar.

Worked example

Suppose a thinly traded stock has exactly one trade between 10:00 and 10:01 at $50.00, then no trades at all until 10:03. A vendor that omits empty bars produces a 10:00 bar at $50.00 and then jumps straight to a 10:03 bar — a strategy scanning bar-by-bar for a price level crossing between 10:01 and 10:02 would simply never see those minutes. A vendor that forward-fills instead emits flat $50.00/$50.00/$50.00/$50.00 bars at 10:01 and 10:02, which correctly represents "nothing changed" but can mislead a volatility calculation into treating those as genuine zero-volatility observations rather than "no data." Neither convention is wrong, but a strategy backtested on one convention and deployed against a live feed using the other will see behavior it didn't expect around illiquid periods.

What this means in practice

Before trusting a backtest, confirm exactly how the data vendor constructs its bars: session filtering, auction-anchored open/close versus raw first/last trade, and gap-handling policy. These choices matter most for less liquid instruments and short bar intervals, where a single convention difference can be the entire reason a signal that worked in a backtest doesn't reproduce against a different data source or a live feed.

An OHLC bar hides several silent conventions — which trades are included (session filtering, lot size), whether open/close use official auctions or raw first/last trades, and how gaps with no trading are represented. Two vendors' "same" bar can differ meaningfully, especially for illiquid instruments and short intervals.

Related concepts

Practice in interviews

Further reading

  • CME and Nasdaq market data specifications, OHLC bar definitions
ShareTwitterLinkedIn