Skip to content
All library documents

Aggregating Tick Data into Range Bars When Prices Overshoot

Article Quant Q&A · Author: Andrii Kubrak

Summary

The document asks how to construct range bars of a fixed price range from tick-like OHLCV records when a price move exceeds the target range. It seeks rules for the number of bars produced and how to assign each bar’s open, high, low, close, and volume, and provides sample records with a range of two price units.

The response warns that OHLC records do not reveal whether the high or low occurred first, so they cannot uniquely determine the intrabar path or bar construction. It suggests forming an ordered sequence from high, low, and close values, then assigning observations to range-sized bins with a numerical binning method. This is only a sketch: it does not define a canonical ordering, explain how to handle overshoots or volume allocation, or convert the supplied sample. The result therefore depends on path and aggregation conventions, and OHLCV data alone may be insufficient to recover tick-accurate range bars.

Key ideas

  • OHLC data does not show whether the high or low happened first within an interval.
  • Range bar construction from OHLC records therefore depends on assumptions about price order.
  • The response suggests assigning an ordered price sequence to bins sized by the target range.
  • The proposed outline does not specify overshoot handling or how volume is split across bars.
  • The sample data is not actually converted into range-bar OHLCV records.

Tags

Full text
# Ticks aggregation into range bar chart


# Ticks aggregation into range bar chart












I have ticks data in format: Date, Time, Open, High, Low, Close, Volume. 11/09/2014,17:00:00,2019.00,2019.00,2019.00,2019.00,5 11/09/2014,17:00:00,2020.00,2020.00,2020.00,2020.00,25 11/09/2014,17:00:00,2028.00,2028.00,2028.00,2028.00,20 11/09/2014,17:00:00,2030.00,2030.00,2030.00,2030.00,10 11/09/2014,17:00:00,2035.00,2035.00,2035.00,2035.00,30 11/09/2014,17:00:00,2037.00,2037.00,2037.00,2037.00,15 11/09/2014,17:00:00,2038.00,2038.00,2038.00,2038.00,10 11/09/2014,17:00:00,2040.00,2040.00,2040.00,2040.00,40

I am trying to construct range bars from this data with range 2.00. It is clear for me how to built that if difference between high and low reaches strictly 2.00. But there are some cases when that difference becomes more than 2.00. So how many bars will be present in this case? What open, high, low, close, volume values will these bars have? I would very appreciate if somebody give me an explanation and convert data I provided to Open, High, Low, Close, Volume format.

## Answer by jignesh patel (score -1)

https://quant.stackexchange.com/a/53305

if you are using OHLC data, you are not sure if High is first or low is first.

you have to convert data to numpy series first e.g. H -L- C- H- L- C-H-L-C create numpy range from maximum to minimum value in the range with bin size as your range bar size use numpy.digitize function to fill the bins.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.