Building Higher-Timeframe Bars for Intraday Strategy Backtests
Summary
The forum exchange explains how to test strategies whose decisions are made on bars longer than one minute in vn.py. It describes feeding one-minute bars into a BarGenerator and running the strategy logic when the requested aggregate bar is complete. The same approach is presented for periods such as five, ten, or thirty minutes. The backtester is said to load one-minute data, with aggregation performed inside the strategy; the reply adds that tick-based testing can use tick data as input instead.
The post includes a moving-average example, but it does not report test results or fully explain data alignment, incomplete bars, or execution assumptions. It also leaves unclear how the example’s strategy array manager receives aggregated bars, so users must verify that indicators are updated from the intended timeframe. Aggregating finer data can preserve intrabar information for simulation, but this post does not establish that it prevents signal loss or produces realistic fills. Sufficient underlying history is needed to construct the desired bars.
Key ideas
- A BarGenerator can combine one-minute input bars into longer bars for strategy logic.
- The backtest can load one-minute data while the strategy acts on completed aggregated bars.
- Changing the aggregation interval supports other custom minute periods.
- The forum response suggests tick data as an alternative input for tick-based testing.
- The example does not explain bar alignment, indicator updates, or execution realism.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.